Repository navigation
perf: avoid repeated row copies in literal CASE branches - #27160
Open
killme2008 wants to merge 3 commits into
Open
killme2008 wants to merge 3 commits into
killme2008 wants to merge 3 commits into
Conversation
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
Contributor
Author
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.
Which issue does this PR close?
Related: GreptimeTeam#38
Rationale for this change
CASE expressions with literal WHEN values and nonliteral THEN expressions repeatedly copy unmatched rows, including string keys in partitioned join filters.
What changes are included in this PR?
Keep remaining row indices between branches and materialize selected rows for THEN/ELSE. Nonliteral WHEN expressions retain the existing path.
Performance measurements below use
e6dfc8f8f9, including the nested-field-name compatibility fix.Baseline
90b55e38b, M4 Max/48 GiB, Rust 1.99.1,release-nonlto; 8,192 rows and two 32-byte string keys. Criterion: ABA/BAB/ABA, 20 samples, 0.5s warmup and 1s measurement per block; three-round means:Uniform 4/16-branch maximum bracket drift was 3.9%. The 50% match case measured 1.041×/1.002×/1.025× across rounds, with maximum drift 2.4%. The mean change in the 50% match case is smaller than its maximum bracket drift.
The existing integer-column CASE measured 1.087× with maximum drift 5.1%. Unchanged lookup/no-base controls ranged from 1.000× to 1.005×; their maximum bracket drift was 11.6%.
What is the testing strategy for this PR?
Physical-expression tests cover row mapping, duplicate/NULL WHEN branches, error short-circuiting, zero-column batches and differing nested field names. The benchmark checks output before timing. Extended workspace tests (13,529 passed, 8 ignored), 546 SQLLogicTest files, clippy and formatting pass.
Are there any user-facing changes?
Performance only; SQL semantics and APIs are unchanged.