Single row select query: any configuration to improve performance vs pyodbc? #767
Replies: 2 comments 1 reply
|
The benchmark does not look misconfigured. It is measuring a real case where mature The important clue is the shape of the results, not just the ratio:
The same repository shows mssql-python winning once more rows are amortized per call and when threads are added. That strongly suggests fixed per-execution/per-row driver overhead rather than network, query plan, connection setup, or a missing pooling switch. The current mssql-python path already reuses the statement handle and prepared plan for repeated identical SQL. However each Two useful measurements would make this actionable for the maintainers:
Also test a stored procedure or set-based request that returns several needed point lookups at once. For production, batching/chunking queries or using concurrency will usually save much more than a connection-string option. If the workload truly must remain synchronous one-row RPCs, keeping pyodbc for that path is a reasonable engineering choice; mssql-python's advantages are workload-dependent, not a promise that every DB-API call is faster. Related maintainers' discussion: #554 |
|
Mauro Antonino (@MauroAntonino) Those measurements are very useful. They move the conclusion from “single-row work has fixed overhead” to “the remaining difference is concentrated in the repeated-text The comment-variant experiment is a strong lead, with one caveat: changing the SQL text changes both any client-side statement reuse and the server-side batch/plan-cache path. It does not yet isolate which layer gives pyodbc the larger repeated-text gain. Your separate For a maintainer-facing issue, I would report exactly these three observations:
A valuable next control is to compare both drivers with a deliberately non-cacheable server execution mode, then compare the repeated-text and variant-text cases again. That would distinguish client statement reuse from SQL Server plan-cache effects. At this point the benchmark is strong enough to file as a focused performance issue with the scenario-5 link and environment details, rather than looking for a connection-string tuning switch. |
Uh oh!
There was an error while loading. Please reload this page.
Hi! I've been evaluating whether to adopt mssql-python for the Python services at the company I work for, and built a simple reproducible benchmark to measure our own workload: https://github.com/MauroAntonino/pyodbc-vs-mssql-python
Most scenarios favour mssql-python. The one we don't understand is the one we run most: a single-row
SELECT. Can you help us understand if something is misconfigured on our side?All reactions