Commit a842b42
committed
cache the index of named parameters
The commit changes bind to cache the position of named parameters, which
improves the performance of prepared queries that are re-used.
```
goos: darwin
goarch: arm64
pkg: github.com/charlievieth/go-sqlite3
cpu: Apple M4 Pro
│ o10.txt │ n10.txt │
│ sec/op │ sec/op vs base │
Scan10Cols-14 4.279µ ± 0% 4.264µ ± 3% ~ (p=0.579 n=10)
Suite/BenchmarkExec/Params-14 715.2n ± 1% 716.3n ± 1% ~ (p=0.927 n=10)
Suite/BenchmarkExec/NoParams-14 533.1n ± 2% 517.9n ± 3% -2.86% (p=0.001 n=10)
Suite/BenchmarkExecContext/Params-14 1.560µ ± 4% 1.504µ ± 0% -3.56% (p=0.000 n=10)
Suite/BenchmarkExecContext/NoParams-14 1.523µ ± 2% 1.518µ ± 1% ~ (p=1.000 n=10)
Suite/BenchmarkExecStep-14 452.5µ ± 2% 444.6µ ± 1% -1.76% (p=0.015 n=10)
Suite/BenchmarkExecContextStep-14 444.1µ ± 2% 451.7µ ± 1% +1.72% (p=0.043 n=10)
Suite/BenchmarkExecTx-14 1.607µ ± 1% 1.585µ ± 1% -1.40% (p=0.000 n=10)
Suite/BenchmarkQuery-14 1.757µ ± 1% 1.784µ ± 0% +1.51% (p=0.001 n=10)
Suite/BenchmarkQuerySimple-14 1.008µ ± 2% 1.015µ ± 1% ~ (p=0.117 n=10)
Suite/BenchmarkQueryContext/Background-14 2.380µ ± 1% 2.315µ ± 0% -2.73% (p=0.001 n=10)
Suite/BenchmarkQueryContext/WithCancel-14 8.314µ ± 1% 8.236µ ± 4% ~ (p=0.225 n=10)
Suite/BenchmarkParams-14 1.952µ ± 1% 2.012µ ± 1% +3.07% (p=0.000 n=10)
Suite/BenchmarkStmt-14 1.373µ ± 1% 1.394µ ± 1% +1.57% (p=0.001 n=10)
Suite/BenchmarkRows-14 58.61µ ± 3% 59.95µ ± 1% +2.29% (p=0.029 n=10)
Suite/BenchmarkStmtRows-14 58.80µ ± 2% 59.82µ ± 2% +1.73% (p=0.050 n=10)
Suite/BenchmarkStmt10Cols-14 4.409µ ± 1% 4.466µ ± 0% +1.30% (p=0.006 n=10)
Suite/BenchmarkScanRawBytes-14 2.499µ ± 1% 2.470µ ± 1% -1.18% (p=0.001 n=10)
Suite/BenchmarkQueryParallel-14 438.3n ± 5% 439.0n ± 4% ~ (p=0.812 n=10)
Suite/BenchmarkOpen-14 13.13µ ± 1% 13.05µ ± 2% ~ (p=0.197 n=10)
Suite/BenchmarkNamedParams-14 1.675µ ± 1% 1.196µ ± 2% -28.60% (p=0.000 n=10)
Suite/BenchmarkParseTime-14 1.040µ ± 2% 1.019µ ± 2% -2.02% (p=0.000 n=10)
geomean 4.173µ 4.102µ -1.69%
│ o10.txt │ n10.txt │
│ B/op │ B/op vs base │
Scan10Cols-14 712.0 ± 0% 712.0 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkExec/Params-14 200.0 ± 0% 216.0 ± 0% +8.00% (p=0.000 n=10)
Suite/BenchmarkExec/NoParams-14 64.00 ± 0% 64.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkExecContext/Params-14 360.0 ± 0% 376.0 ± 0% +4.44% (p=0.000 n=10)
Suite/BenchmarkExecContext/NoParams-14 208.0 ± 0% 208.0 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkExecStep-14 64.00 ± 0% 64.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkExecContextStep-14 208.0 ± 0% 208.0 ± 0% ~ (p=1.000 n=10)
Suite/BenchmarkExecTx-14 520.0 ± 0% 520.0 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkQuery-14 640.0 ± 0% 656.0 ± 0% +2.50% (p=0.000 n=10)
Suite/BenchmarkQuerySimple-14 440.0 ± 0% 456.0 ± 0% +3.64% (p=0.000 n=10)
Suite/BenchmarkQueryContext/Background-14 396.0 ± 0% 396.0 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkQueryContext/WithCancel-14 1.016Ki ± 0% 1.015Ki ± 0% ~ (p=0.121 n=10)
Suite/BenchmarkParams-14 784.0 ± 0% 800.0 ± 0% +2.04% (p=0.000 n=10)
Suite/BenchmarkStmt-14 784.0 ± 0% 784.0 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkRows-14 6.047Ki ± 0% 6.062Ki ± 0% +0.26% (p=0.000 n=10)
Suite/BenchmarkStmtRows-14 6.055Ki ± 0% 6.055Ki ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkStmt10Cols-14 712.0 ± 0% 712.0 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkScanRawBytes-14 592.0 ± 0% 592.0 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkQueryParallel-14 532.0 ± 0% 548.0 ± 0% +3.01% (p=0.000 n=10)
Suite/BenchmarkOpen-14 111.0 ± 1% 111.0 ± 1% ~ (p=1.000 n=10)
Suite/BenchmarkNamedParams-14 664.0 ± 0% 600.0 ± 0% -9.64% (p=0.000 n=10)
Suite/BenchmarkParseTime-14 444.0 ± 0% 444.0 ± 0% ~ (p=1.000 n=10) ¹
geomean 479.5 482.4 +0.60%
¹ all samples are equal
│ o10.txt │ n10.txt │
│ allocs/op │ allocs/op vs base │
Scan10Cols-14 19.00 ± 0% 19.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkExec/Params-14 8.000 ± 0% 8.000 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkExec/NoParams-14 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkExecContext/Params-14 10.00 ± 0% 10.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkExecContext/NoParams-14 6.000 ± 0% 6.000 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkExecStep-14 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkExecContextStep-14 6.000 ± 0% 6.000 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkExecTx-14 18.00 ± 0% 18.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkQuery-14 22.00 ± 0% 22.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkQuerySimple-14 13.00 ± 0% 13.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkQueryContext/Background-14 10.00 ± 0% 10.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkQueryContext/WithCancel-14 26.00 ± 0% 26.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkParams-14 23.00 ± 0% 23.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkStmt-14 23.00 ± 0% 23.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkRows-14 418.0 ± 0% 418.0 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkStmtRows-14 418.0 ± 0% 418.0 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkStmt10Cols-14 19.00 ± 0% 19.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkScanRawBytes-14 18.00 ± 0% 18.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkQueryParallel-14 15.00 ± 0% 15.00 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkOpen-14 3.000 ± 0% 3.000 ± 0% ~ (p=1.000 n=10) ¹
Suite/BenchmarkNamedParams-14 14.00 ± 0% 13.00 ± 0% -7.14% (p=0.000 n=10)
Suite/BenchmarkParseTime-14 12.00 ± 0% 12.00 ± 0% ~ (p=1.000 n=10) ¹
geomean 15.93 15.87 -0.34%
¹ all samples are equal
```1 parent 8d4a09e commit a842b42
2 files changed
+251
-54
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
602 | 602 | | |
603 | 603 | | |
604 | 604 | | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
611 | 612 | | |
612 | 613 | | |
613 | 614 | | |
| |||
2328 | 2329 | | |
2329 | 2330 | | |
2330 | 2331 | | |
2331 | | - | |
2332 | | - | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
2333 | 2361 | | |
2334 | 2362 | | |
2335 | 2363 | | |
| |||
2338 | 2366 | | |
2339 | 2367 | | |
2340 | 2368 | | |
2341 | | - | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
2342 | 2390 | | |
2343 | | - | |
| 2391 | + | |
2344 | 2392 | | |
2345 | | - | |
2346 | | - | |
2347 | | - | |
2348 | | - | |
2349 | | - | |
2350 | | - | |
2351 | | - | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
2352 | 2397 | | |
2353 | 2398 | | |
2354 | 2399 | | |
2355 | 2400 | | |
2356 | 2401 | | |
2357 | | - | |
2358 | | - | |
2359 | | - | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
2360 | 2418 | | |
2361 | | - | |
2362 | | - | |
2363 | | - | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
2364 | 2424 | | |
2365 | | - | |
2366 | | - | |
2367 | | - | |
2368 | | - | |
2369 | | - | |
2370 | | - | |
2371 | | - | |
2372 | | - | |
2373 | | - | |
2374 | | - | |
2375 | | - | |
2376 | | - | |
2377 | | - | |
2378 | | - | |
2379 | | - | |
2380 | | - | |
2381 | | - | |
2382 | | - | |
2383 | | - | |
2384 | | - | |
2385 | | - | |
2386 | | - | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
2387 | 2429 | | |
2388 | | - | |
2389 | | - | |
2390 | | - | |
2391 | | - | |
2392 | | - | |
2393 | | - | |
| 2430 | + | |
2394 | 2431 | | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
2395 | 2438 | | |
2396 | 2439 | | |
2397 | 2440 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1093 | 1093 | | |
1094 | 1094 | | |
1095 | 1095 | | |
1096 | | - | |
1097 | | - | |
1098 | 1096 | | |
1099 | 1097 | | |
1100 | 1098 | | |
| |||
2346 | 2344 | | |
2347 | 2345 | | |
2348 | 2346 | | |
2349 | | - | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
2350 | 2350 | | |
2351 | 2351 | | |
2352 | 2352 | | |
| |||
2376 | 2376 | | |
2377 | 2377 | | |
2378 | 2378 | | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
2379 | 2440 | | |
2380 | 2441 | | |
2381 | 2442 | | |
| |||
2555 | 2616 | | |
2556 | 2617 | | |
2557 | 2618 | | |
| 2619 | + | |
2558 | 2620 | | |
2559 | 2621 | | |
2560 | 2622 | | |
| |||
3337 | 3399 | | |
3338 | 3400 | | |
3339 | 3401 | | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
| 3408 | + | |
| 3409 | + | |
| 3410 | + | |
| 3411 | + | |
| 3412 | + | |
| 3413 | + | |
| 3414 | + | |
| 3415 | + | |
| 3416 | + | |
| 3417 | + | |
| 3418 | + | |
| 3419 | + | |
| 3420 | + | |
| 3421 | + | |
| 3422 | + | |
| 3423 | + | |
| 3424 | + | |
| 3425 | + | |
| 3426 | + | |
| 3427 | + | |
| 3428 | + | |
| 3429 | + | |
| 3430 | + | |
| 3431 | + | |
| 3432 | + | |
| 3433 | + | |
| 3434 | + | |
| 3435 | + | |
| 3436 | + | |
| 3437 | + | |
| 3438 | + | |
| 3439 | + | |
| 3440 | + | |
| 3441 | + | |
| 3442 | + | |
| 3443 | + | |
| 3444 | + | |
| 3445 | + | |
| 3446 | + | |
| 3447 | + | |
| 3448 | + | |
| 3449 | + | |
| 3450 | + | |
| 3451 | + | |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
| 3458 | + | |
| 3459 | + | |
| 3460 | + | |
| 3461 | + | |
| 3462 | + | |
| 3463 | + | |
| 3464 | + | |
3340 | 3465 | | |
3341 | 3466 | | |
3342 | 3467 | | |
| |||
3379 | 3504 | | |
3380 | 3505 | | |
3381 | 3506 | | |
| 3507 | + | |
| 3508 | + | |
| 3509 | + | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + | |
| 3519 | + | |
| 3520 | + | |
| 3521 | + | |
| 3522 | + | |
| 3523 | + | |
| 3524 | + | |
| 3525 | + | |
| 3526 | + | |
| 3527 | + | |
| 3528 | + | |
| 3529 | + | |
| 3530 | + | |
| 3531 | + | |
| 3532 | + | |
| 3533 | + | |
| 3534 | + | |
| 3535 | + | |
0 commit comments