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
For I/O-bound operations, the async driver's overhead becomes negligible compared to disk I/O wait time. The ability to interleave other work becomes an advantage - the event loop can process other tasks while waiting for data.
170
171
172
+
### Long Query Performance
173
+
174
+
With such a small amount of data we are currently using, it's not so easy to simulate longer running queries. That's why I tried it here using simple aggregation.
175
+
176
+
Aggregate functions (COUNT, SUM, AVG, MIN, MAX) with WHERE clauses show even more dramatic async advantages:
177
+
178
+
```
179
+
--- aggregate functions (COUNT, SUM, AVG, MIN, MAX) with WHERE clause ---
180
+
better-sqlite3 x 11,246 ops/sec ±0.27% (event loop: 100%, 88.9μs/op)
181
+
@homeofthings/sqlite3 x 68,779 ops/sec ±0.60% (event loop: 47%, 6.8μs/op)
182
+
node:sqlite x 10,982 ops/sec ±0.40% (event loop: 100%, 91.1μs/op)
183
+
```
184
+
185
+
**Why async wins for aggregation:**
186
+
187
+
1. **6x higher throughput**: 68,779 vs 11,246 ops/sec
188
+
2. **13x less event loop blocking**: 6.8μs/op vs 88.9μs/op
189
+
3. **Same pattern as large data**: I/O-bound operations benefit from async
190
+
191
+
Aggregation queries scan 1000 rows per operation. The async driver's ability to yield during I/O makes it significantly more efficient for these multi-row operations.
192
+
171
193
## Project Structure
172
194
173
195
```
@@ -180,6 +202,7 @@ For I/O-bound operations, the async driver's overhead becomes negligible compare
0 commit comments