You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `efficient` scaling strategy provides optimized pool growth behavior that only creates new connections when existing idle connections are exhausted. This addresses the inefficiency in the default `aggressive` strategy where the pool grows to the ceiling immediately on open.
6
+
7
+
## Problem Solved
8
+
9
+
The original pool behavior had these inefficiencies:
10
+
11
+
1.**Eager growth**: With `aggressive` strategy, pools grew to ceiling immediately on open
12
+
2.**Unnecessary connections**: Created connections even when idle ones were available
13
+
3.**Resource waste**: Maintained more connections than needed for typical workloads
14
+
15
+
## Solution: Efficient Strategy
16
+
17
+
### Behavior
18
+
19
+
-**Initial creation**: Creates connections only up to `floor` on pool open
20
+
-**Conservative growth**: Only grows when work queue exceeds idle connections
21
+
-**Incremental scaling**: Adds connections based on actual demand
22
+
23
+
### Usage
24
+
25
+
```javascript
26
+
constpool=newsql.Pool({
27
+
connectionString:'...',
28
+
floor:5, // Start with 5 connections
29
+
ceiling:20, // Maximum 20 connections
30
+
scalingStrategy:'efficient', // Use efficient strategy
31
+
scalingIncrement:3// Grow by 3 when needed
32
+
})
33
+
```
34
+
35
+
### Comparison of Strategies
36
+
37
+
| Strategy | Initial Growth | Additional Growth | Use Case |
0 commit comments