Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterised query benchmark #82

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

Mike-Dax
Copy link
Contributor

This PR adds a benchmark to compare the performance of parameterising a query.

The statistically significant takeaway by my reading is:

  • It's faster to prepare once then re-bind parameters multiple times if possible.
  • If the query can't be parameterised, calling prepare and binding every time has an overhead that can be avoided with a simpler run call.
 ✓ test/bench/prepare.bench.ts (3) 2041ms
   ✓ Parameterised queries (3) 2040ms
     name                        hz     min     max    mean     p75     p99    p995    p999     rme  samples
   · Multiple queries      2,634.62  0.2616  5.2889  0.3796  0.3935  0.5699  0.6606  4.9380  ±2.84%     1318
   · Prepared with re-use  2,908.72  0.2303  5.0928  0.3438  0.3634  0.5307  0.5631  4.3680  ±2.58%     1455   fastest
   · Prepared each time    2,371.56  0.3070  6.8511  0.4217  0.4347  0.7030  0.9216  5.2908  ±3.33%     1186   slowest
```

@jraymakers
Copy link
Contributor

Thanks! Interesting (but not surprising) that prepared statements have a slight overhead when not re-used.

@jraymakers jraymakers merged commit 94f0160 into duckdb:main Dec 24, 2024
5 checks passed
@Mike-Dax Mike-Dax deleted the parameterised-query-benchmark branch December 25, 2024 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants