Preserve runtime bounds in generic ranked scans - #36
Merged
Merged
Conversation
bweis
added this pull request to stack #33
September 19, 2026 22:44
bweis
force-pushed
the
perf/runtime-ranked-bounds
branch
from
September 19, 2026 22:50
076a05f to
efb1e8a
Compare
bweis
marked this pull request as ready for review
September 19, 2026 22:58
bweis
force-pushed
the
perf/runtime-ranked-bounds
branch
from
September 19, 2026 23:03
d304152 to
0175bb3
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.
Generic ranked queries with parameterized LIMIT/OFFSET previously lost their top-k bound and ranked all candidates. Bind simple bigint bounds at execution so eligible scans can use existing block-max pruning, rebinding on rescans. NULL, overflow, WITH TIES, and visibility checks retain correct fallback behavior; PostgreSQL still owns negative-bound errors.
A validated 100k Wikipedia A/B/B/A comparison found about 46% lower server latency for broad OR LIMIT 10 and 33% lower for LIMIT 100 OFFSET20. The first implementation regressed a filtered query by 54%; the final change conservatively excludes residual SQL quals, restoring that case to roughly unchanged latency. Existing literal-limit behavior and unsupported expressions/query shapes remain unchanged.
Proof: docs/benchmarks/runtime-ranked-bounds.md and runtime-ranked-results.json include frozen source/image identities, all round medians, plans, and actual visibility-map controls. Both campaigns passed 60/60 exact ordered-score/membership checks. The existing server-time collector now supports prepared SQL cases and alternating measurement order.
Validation: native ARM Docker build passed; 123 Python harness tests and formatting passed. The original implementation passed ARM/x86 PostgreSQL 17/18 tests and upstream Lead checks; final-head CI must pass before merge. Stacked on #32.