Repository navigation
perf(thrift): fetch more inline rows per round trip for fetchall and large fetchmany - #1033
Open
vuanhphung wants to merge 1 commit into
Open
vuanhphung wants to merge 1 commit into
vuanhphung wants to merge 1 commit into
Conversation
…large fetchmany Every FetchResults asked for arraysize (100k) rows, so a 10M-row boolean result took 97 round trips although each reply was tiny. fetchall*() and fetchmany*(size > arraysize) now ask for the rows they still need, capped at 2M rows (the JDBC driver's limit). fetchone(), iteration and fetchmany(size <= arraysize) still send arraysize, and replies stay bounded by maxBytes. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
vuanhphung
temporarily deployed
to
azure-prod
November 12, 2026 09:32 — with
GitHub Actions
Inactive
vuanhphung
temporarily deployed
to
azure-prod
November 12, 2026 09:32 — with
GitHub Actions
Inactive
This branch was previously deployed
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.
What type of PR is this?
Description
On Thrift, every FetchResults asks for
arraysizerows (100k by default), even when the caller has already asked for everything. For narrow inline results that cap is what limits throughput, not the reply size. A 10M-row boolean result comes back inline, about 100k rows (a few hundred KB) per reply, sofetchall_arrow()took 97 round trips and ~6 s.ThriftResultSet._fill_results_buffernow takes the number of rows the caller still needs.fetchall()/fetchall_arrow()andfetchmany(size)/fetchmany_arrow(size)withsize > arraysizerequest those rows, capped at 2M per call (the JDBC driver's limit).fetchone(), iteration andfetchmany(size <= arraysize)still sendmaxRows = arraysize, so streaming consumers keep their batch size.maxBytesis unchanged, and the server bounds each inline reply by bytes. For wide rows it already returned only 61,440 rows (~3.9 MB) per reply whethermaxRowswas 100k or 2M, so wide results neither gain nor lose. CloudFetch links ignoremaxRows, so CloudFetch is unaffected. Column-based results (no pyarrow, and metadata calls) use the same code; the no-pyarrow case is in the table. The SEA and kernel result sets don't use this code.This touches
_fill_results_bufferlike #1030, so whichever merges second needs a trivial rebase.Live A/B against a PRO warehouse (Thrift; fresh processes, main and this PR interleaved, warm-up discarded, n=5 each; fetch = time after
execute()returns):fetchall_arrowfetchall_arrowfetchall_arrowfetchallfetchmany_arrow(1_000_000)fetchmany(10_000)(streaming)How is this tested?
New unit tests use a fake server that honours
maxRowsexactly. They pin the rows requested for each fetch method on Arrow and column-based results:arraysizeforfetchone, iteration and smallfetchmany; the remaining rows for largefetchmany; up to the cap forfetchall. They also cover the cap and anarraysizeabove it, and check that row order is exact across batches. The full unit suite passes. Against a live warehouse, thetest_driver.pye2e tests pass (35 passed, Thrift and SEA): large wide/narrow results, async large results,fetchone/fetchall/fetchmany/iteration, Arrow fetches, row limits, cancel, and the metadata calls (tables,columns,schemas,catalogs).Related Tickets & Documents
N/A
This pull request and its description were written by Isaac.