Optimize data retrieval via the cursor object#196
Open
TheDistributor wants to merge 1 commit into
Open
Conversation
Accelerate data retrieval pathways in the Cursor class by optimizing row iteration and reducing interpreter overhead on high-frequency method loops. Detailed changes: - fetchone: Inline the `_check_closed()` state verification directly into the method body. This removes function-call stack overhead for every individual row retrieved. - fetchall: Refactor the loop to slice and drain the current in-memory result batch in bulk using `list.extend()` instead of sequentially invoking `fetchone()` row by row. - fetchall: Directly request the next network payload batch via `fetch_result_set_next` once the in-memory collection is exhausted, updating total `rownumber` tracking as a single block operation. - fetchall: Add a defensive guard clause against unallocated result sets to ensure strict DB-API compatibility.
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.
Accelerate data retrieval pathways in the Cursor class by optimizing row iteration and reducing interpreter overhead on high-frequency method loops.
Detailed changes:
_check_closed()state verification directly into the method body. This removes function-call stack overhead for every individual row retrieved.list.extend()instead of sequentially invokingfetchone()row by row.fetch_result_set_nextonce the in-memory collection is exhausted, updating totalrownumbertracking as a single block operation.Approx 5% improvement using FetchTest.py and the mxproperty workload.