Fetch tuples in small batches in adaptive executor where possible#5195
Open
marcocitus wants to merge 2 commits intomainfrom
Open
Fetch tuples in small batches in adaptive executor where possible#5195marcocitus wants to merge 2 commits intomainfrom
marcocitus wants to merge 2 commits intomainfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5195 +/- ##
=======================================
Coverage 88.90% 88.90%
=======================================
Files 286 286
Lines 63227 63304 +77
Branches 7937 7950 +13
=======================================
+ Hits 56214 56283 +69
- Misses 4736 4744 +8
Partials 2277 2277 🚀 New features to boost your workflow:
|
marcocitus
commented
Aug 20, 2021
| ResetExplainAnalyzeData(taskList); | ||
| MemoryContext memoryContext = AllocSetContextCreate(executorState->es_query_cxt, | ||
| "AdaptiveExecutor", | ||
| ALLOCSET_DEFAULT_SIZES); |
Contributor
Author
There was a problem hiding this comment.
TODO: maybe reset this context at the very end since it uses es_query_ctx
marcocitus
commented
Aug 20, 2021
| execution->rowsReceivedInCurrentRun = 0; | ||
|
|
||
| /* TODO: GUC? be smart? */ | ||
| int maxBatchSize = 10000; |
Contributor
Author
There was a problem hiding this comment.
TODO: pick batch size
|
I hope this feature makes it in. :-) |
f33de24 to
a8d14ee
Compare
Contributor
Author
|
@microsoft-github-policy-service agree [company="Snowflake"] Though this work was done during my Microsoft/Citus Data tenure, so already belongs to Microsoft. |
Contributor
Author
|
@microsoft-github-policy-service agree |
c140524 to
4200722
Compare
…d execution, tests. - Resource clean-up: AdaptiveExecutorEnd() releases sessions/connections when an error occurs between AdaptiveExecutorRun calls. Also handle early termination (cursor close, LIMIT satisfied) with proper clean-up of in-flight worker queries. - ShouldRunTasksSequentially() check in FinishDistributedExecution() replaced with explicit sessionsCleanedUp flag on DistributedExecution struct. Fixes double CleanUpSessions on sequential path. - Adaptive batch sizing via citus.executor_batch_size (default 0 => auto). Auto mode calculates batch size from work_mem and TupleDesc (attlen + typmod for varlena, 128B default for unbounded). Floor 100, ceiling 1M rows. - Remote execution uses LibPQ's chunked mode (PG17+), GUC configurable for now. - Local execution is eager; it runs to completion. - Regress test suite: 11 test cases covering batch sizes 1/10/100K/auto, empty results, LIMIT, aggregation, DML RETURNING, GUC behavior, between-batch error cleanup, cursor close mid-batch and cross-batch-size result consistency.
4200722 to
eb1bc1d
Compare
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.
DESCRIPTION: Fetch tuples in small batches in adaptive executor where possible
This PR makes RunDistributedExecution reentrant such that we avoid creating an excessively large tuple store for queries that do not require materialization. This is beneficial to restrict memory usage, avoid unnecessary disk I/O and thereby improve performance of queries with large result sets.
It does not cover local execution (seems somewhat important) and multi-row inserts (seems unimportant) yet.