PERF: Keep fetchmany column metadata native and call-local - #796
Draft
Jahnvi Thakkar (jahnvi480) wants to merge 1 commit into
Draft
Jahnvi Thakkar (jahnvi480) wants to merge 1 commit into
Jahnvi Thakkar (jahnvi480) wants to merge 1 commit into
Conversation
Remove native metadata dictionary roundtrips while preserving eager Unicode names and fresh per-call descriptions. Add behavior and profiling regression coverage. Performance acceptance remains unresolved after the bounded local study. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Jahnvi Thakkar (jahnvi480)
September 17, 2026 15:53
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The declared performance acceptance and no-regression gates remain unresolved, including failed A/A stability results.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Refactors fetchmany() metadata handling to avoid Python dictionary round-trips while preserving public descriptions and existing fetch behavior.
Changes:
- Adds call-local native metadata structures and shared description logic.
- Adds comprehensive fetch, metadata, lifecycle, and profiling tests.
- Documents the behavior change in the changelog.
File summaries
| File | Description |
|---|---|
mssql_python/pybind/ddbc_bindings.cpp |
Uses native metadata for fetchmany(). |
tests/test_040_fetch_native_metadata.py |
Adds regression and profiling coverage. |
CHANGELOG.md |
Documents the metadata refactor. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
mssql_python/pybind/ddbc_bindings.cppLines 3055-3066 3055
3056 SQLULEN GetFetchColumnSize(const FetchColumnMetadata& column) {
3057 return column.columnSize;
3058 }
! 3059
3060 std::string GetFetchColumnName(const py::dict& column) {
! 3061 return column["ColumnName"].cast<std::string>();
! 3062 }
3063
3064 std::string GetFetchColumnName(const FetchColumnMetadata& column) {
3065 return column.name.cast<std::string>();
3066 }Lines 3109-3117 3109
3110 } // namespace
3111
3112 // Wrap SQLDescribeCol
! 3113 SQLRETURN SQLDescribeCol_wrap(SqlHandlePtr StatementHandle, py::list& ColumnMetadata) {
3114 PERF_TIMER("SQLDescribeCol_wrap");
3115 return DescribeColumns(StatementHandle, [&](FetchColumnMetadata column) {
3116 ColumnMetadata.append(
3117 py::dict("ColumnName"_a = column.name, "DataType"_a = column.dataType,📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.performance_counter.hpp: 0.7%
mssql_python.pybind.logger_bridge.cpp: 57.9%
mssql_python.pybind.ddbc_bindings.h: 61.5%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.row.py: 77.6%
mssql_python.pybind.ddbc_bindings.cpp: 77.9%
mssql_python.pybind.connection.connection_pool.cpp: 81.8%
mssql_python.logging.py: 86.2%
mssql_python.pooling.py: 90.1%
mssql_python.pybind.py_type_cache.hpp: 91.6%🔗 Quick Links
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
Keep
fetchmany()column metadata native within each call instead of building Python dictionaries and immediately unpacking them again in C++. Small batches repeat this setup frequently, so avoiding the roundtrip reduces driver-side work.The implementation shares one checked description loop and lets the existing binding and batch code read native fields. Fresh ODBC descriptions, eager Unicode-name conversion, public metadata output and existing fetch behavior are unchanged. There is no cross-call cache or hidden prefetch;
fetchall()and Arrow retain their existing setup.flowchart LR subgraph Before B1["Fresh descriptions"] --> B2["Python dictionaries"] --> B3["C++ field extraction"] --> B4["Bind/fetch"] end subgraph After A1["Fresh descriptions"] --> A2["Native fields + owned Unicode names"] --> A3["Same bind/fetch"] endMatched Windows x64/Python 3.13 OFF-Release measurements: 10,000 rows, 24 columns, 12 paired rounds and 9 drains per case. The table shows median fetch latency.
fetchmany(1)fetchall()controlSeparately instrumented counts for the
fetchmany(1)drain, including EOF, show metadata dictionary emissions falling from 240,024 to 0, while ODBC column descriptions remain 240,024. Owned Python Unicode names still exist.Draft, not merge-ready: same-build calibration was unstable and some controls were slower, so no-regression is not established. The wide-small-fetch result is promising, but it is not a universal-speedup claim.