feat(query): optimize ordered top-k serving#20144
Draft
dbsid wants to merge 6 commits into
Draft
Conversation
dbsid
marked this pull request as ready for review
July 14, 2026 03:35
Contributor
🤖 CI Job Analysis (Retry 1)
📊 Summary
❌ NO RETRY NEEDEDAll failures appear to be code/test issues requiring manual fixes. 🔍 Job Details
🤖 AboutAutomated analysis using job annotations to distinguish infrastructure issues (auto-retried) from code/test issues (manual fixes needed). |
dbsid
marked this pull request as draft
July 14, 2026 05:37
11 tasks
dbsid
force-pushed
the
codex/web3-no-lazy-serving
branch
2 times, most recently
from
July 16, 2026 07:09
ad74790 to
572a8aa
Compare
dbsid
force-pushed
the
codex/web3-no-lazy-serving
branch
from
July 16, 2026 07:54
572a8aa to
79ca6c8
Compare
Author
|
Final head
The prior CI issues are addressed locally: |
This was referenced Jul 16, 2026
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.
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
Supersedes #20031.
This draft combines storage, planner, executor, and MySQL-path changes for the Web3
ORDER BY ... LIMITserving workload without adding a query-result cache or a new planner cache:Sort(PresortedMerge), and allow ordered top-k early stop;The standalone planner-cache commit previously included in this PR has been removed. The remaining five commits are intentionally layered for review.
Rollout guards
max_cluster_key_ordered_topk_overlap=0by default and is the single ordered-top-k off switch.cluster_key_ordered_topk_lazy_read_threshold=1000only applies when max overlap is nonzero; setting it to0disables the specialized lazy path.enable_query_result_cache=0was explicit in every benchmark session.enable_planner_cache=1was also explicit and identical for baseline and PR runs. The removed PR-local setting wasenable_standalone_fast_planner_cache; that symbol and its plan metadata no longer exist in the final diff.Implementation
PresortedMergeearly stop.Benchmark
Driver: https://github.com/dbsid/hbx-web3
Environment:
i4i.4xlarge, 16 vCPU Intel Xeon Platinum 8375C, single query node, S3 inus-west-2;RUSTFLAGS="-C target-cpu=native";max_threads=2,max_storage_io_requests=16, distributed pruning off;2026071305;Binaries:
22a762701e: SHA256590321daac61059e0c90b202e4cddc90e94a6d1d437fa9615c2e4dffff0ec4ec;a3b66d320c: SHA256cde801b67c4182c5aee880dbc981727fe7a57f408b9ddca2b40234ffe21f04b4;79ca6c8f90: SHA2561ecabb0220490224250a427b09ce46686d3c22ed705de8bfe0eadccf9a3326b9.No-lazy speedups are 1.69x/2.15x/2.13x for Q1/Q2/Flex. Against baseline default lazy, speedups are 6.67x/6.07x/6.10x. Final-head lazy and no-lazy means differ by only 0.2%-0.7%, so the PR removes the baseline's large default-lazy penalty. The 10 ms target is not achieved after removing the standalone planner cache.
The table uses an exact final-HEAD S3 rerun. The attribution and page-ablation tables below use
a3b66d320cand adjacent staged binaries so each comparison changes one layer at a time. Final HEAD is 7.0%-10.9% faster than the earlier full run, but that cross-version/run delta is not assigned to a PR layer. The rerun used the i4i instance role after the temporary session files expired.Attribution
Standalone planner cache on the same old PR binary:
SELECT 1Retained commits with the standalone cache absent:
SELECT 1mean msThe retained-code ranking is short-query execution first overall, with page-aware row fetch equally important for Q2/Flex. Composite/prefix page zone maps are not the primary optimization.
Page zone-map result
Page ranges improve latency only 1.8%-3.2%. Full and ablated profiles have identical scan counts:
Page ranges reduce remote bytes (
1.13 MiB -> 911.83 KiBfor Q2 and2.37 MiB -> 1.17 MiBfor Flex), but do not reduce scanned blocks. Persistent composite/prefix page zone maps are therefore not the main optimization for this workload.Correctness
79ca6c8f90) local-storage sqllogic: 105 records passed across ordered top-k lazy read, sort elimination, and data-page options.cargo check -p databend-query,cargo test -p databend-common-settings --lib,cargo test -p databend-common-sql --tests --no-run,cargo fmt --all -- --check,taplo check,taplo fmt --check,typos, andgit diff --checkpassed.Tests
Type of change
This change is