Repository navigation
Optimize LIMIT BY - #103349
Optimize LIMIT BY#103349
LIMIT BY#103349Conversation
|
Workflow [PR], commit [61118e2] Summary: ✅
AI ReviewSummaryThis PR optimizes Findings
Final VerdictStatus: Minimum action: align float key equality between generic and sorted |
|
This was fixed by #105146. Let's update the branch. |
Fgrtue
left a comment
There was a problem hiding this comment.
The implementation looks good to me. I would like to suggest adding a separate test for it, as we usually do this when we add new features of do improvements -- the test could just show that there are two different limit by pipeline processorts exist now.
Other than that I suggested two improvements: 1) Short circuit execution -- probably not so difficult to add; 2) SIMD computation of delimiters between different rows in columns -- probably more involved as it is supposed to add a new method and might even worth another PR. Would be interested knowing your opinion on those suggestions.
|
Thanks for the thorough review!
Actually, the edited test
|
I saw it, but I wanted to propose another one -- a new one, that will designate the appearance of this new processor. So even though we have the old test, we would also have a new one. But this is just a nit, and not critical, so I don't insist. |
Do you want to experiment with the binary search in the sorted version in this PR or in a separate one? |
Okay. Added
I think it will be better if done in a separate PR since it will be done as a new method of |
Fgrtue
left a comment
There was a problem hiding this comment.
Thank you for adding the test. Looking forward to further updates on ordered case.
|
📊 Cloud Performance Report ✅ AI verdict: This PR rewrites only the LIMIT BY execution path, splitting it into a general transform and a new sorted-stream variant. ClickBench Q32 is a GROUP BY / ORDER BY ... LIMIT 10 query with no LIMIT BY clause, so it never touches the changed code. The single flagged delta (5.38% on Q32) is borderline — only one of the two tests flags it, on a query whose measurements were noisy — and is not attributable to this change. No real regression or improvement is evident in the flagged set. clickbenchFlagged queries (1 of 43)
q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 226/234 (96.58%) | Lost baseline coverage: none · Uncovered code |
|
@Fgrtue The binary search idea that I discussed: As expected, it is giving quite of speedup! |
Core Optimizations:
LIMIT BY.LIMIT BYSipHash+HashMap<UInt128, UInt64>path with typed hash methods fromAggregatedDataVariants. This reduces memory usage for many common key types and letsLIMIT BYbenefit from existing optimizations. It also avoids relying on hash equality alone to distinguish keys.IColumn::filter, choose the cheapest strategy for the output: reuse the whole chunk if all rows are part of the output, use fasterIColumn::cutfor contiguous output, and fall back tofilteronly when needed.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Improve performance of
LIMIT BYqueries.Documentation entry for user-facing changes
Version info
26.6.1.414