Skip to content

Preserve runtime bounds in generic ranked scans - #36

Merged
bweis merged 5 commits into
mainfrom
perf/runtime-ranked-bounds
Sep 19, 2026
Merged

bweis merged 5 commits into
mainfrom
perf/runtime-ranked-bounds

Conversation

@bweis

@bweis bweis commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

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.

@bweis
bweis added this pull request to stack #33 September 19, 2026 22:44
@bweis
bweis force-pushed the perf/runtime-ranked-bounds branch from 076a05f to efb1e8a Compare September 19, 2026 22:50
@bweis
bweis marked this pull request as ready for review September 19, 2026 22:58
Base automatically changed from perf/generic-ranked-plans to main September 19, 2026 23:01
@bweis
bweis force-pushed the perf/runtime-ranked-bounds branch from d304152 to 0175bb3 Compare September 19, 2026 23:03
@bweis
bweis merged commit beab760 into main Sep 19, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant