Repository navigation
[4.2-dev] fix(plan): bound covering index range scans - #32930
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
This pull request is merged. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: c5e1d11405cedeb484bf45a062c0d3d7424a1964
Assessment: approve
Reviewed against the pinned 4.2-dev target at 5d0c7e6, with merge-base 7d1cacc. The change reuses the existing serialized-key operators and shares suffix-bound construction across covering scans and index backfill. Matched persisted-data checks confirmed less scan work and identical SQL results.
Model: gpt-6.2-sol / xhigh
Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3
Validation:
-
The full planner suite and focused SQL-function and storage-reader range tests passed. See planner.log, range-consumers.log, and receipts 1795082083215415869-2.json and 1795082120203576922-2.json.
-
An embedded SQL run executed all 58 committed statements, compared 29 result sets, checked four representative plans, and verified database cleanup. On matched flushed fixtures, the forced leading range fell from 9 blocks and 65,539 input rows to 1 block and 5 rows. Selective default JOINs already pruned on the base and had identical scan counts at head. See sql-base-metrics.log, sql-candidate-metrics.log, and receipts 1795082226583406838-2.json and 1795082227131603173-2.json.
-
The paired composite suffix fell from 6 blocks and 49,152 input rows to 1 block and 99 rows on both default and forced covering scans. Covering and backfill results matched the unindexed controls. See sql-base-suffix.log, sql-candidate-suffix.log, and receipts 1795082294896732177-2.json and 1795082296863780411-2.json.
-
Diff hygiene, runtime preflight, and the native prerequisite build passed.
Limitations:
-
The embedded SQL probe checked results and stable plan fragments. The full mo-tester comparison, restart coverage, and the author's 30-million-entry run were outside local validation. Planner and BVT CI coverage was incomplete in the frozen snapshot.
-
A larger probe with out-of-domain in_range flag 4 returned different results on the sorted index and base-table paths on both revisions. The new bound guard preserves the existing fallback for that flag. Early probe failures and the corrected fixture runs are retained in the diagnostic directory.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Commit: c5e1d11405cedeb484bf45a062c0d3d7424a1964
Independent static design review · gpt-6.1-terra / max
No additional confirmed defect was identified within the source paths reviewed. I traced the new integer/literal eligibility and serialized-domain guards, opposing endpoint merging, NULL and composite-prefix handling, and the in-memory and persisted range consumers. Unsupported or potentially throwing expressions and prepared/dynamic operands were checked against the existing fallback paths.
One scope distinction matters: suffix predicates retain decoded row-level conditions, but not every leading integer bound retains the original SQL predicate; some cases rely on the serialized comparison being exact. The nullable one-sided upper-bound path retains a decoded recheck. This review does not establish encoding correctness for every untested value or type.
The same-head Required, x86 UT, arm64 SCA and the proxy/pessimistic multi-CN BVT jobs passed. Upgrade compatibility jobs were skipped. I did not independently run SQL, prepared-statement, restart, extreme-value, multi-CN, persisted-data or performance tests. The author's 30-million-entry result and the other reviewer's smaller persisted-data probes remain their reported evidence, not executions from this review.
|
mo-bot review · Commit: New discussion was assessed; the previous review remains unchanged. |
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #32928.
What this PR does / why we need it:
On 4.2, a forced covering index scan could evaluate a leading range only after decoding every index entry, while an equality-prefix covering scan could leave the next-column range as a row filter. Build serialized bounds at those scan owners and combine compatible opposing endpoints, including for index backfill. Preserve exact SQL rechecks, existing narrower bounds and the previous fallback for unsupported or potentially throwing expressions and invalid range flags.
On the same persisted 30M-entry dataset, the forced
COUNT(DISTINCT)range returned 100 before and after, while index input fell from 3,720 blocks / 30M rows to 480 blocks / 3M rows. This was a single-CN local scan-work comparison, not a latency benchmark. New covering and paired-bound lowering is conservative for dynamic or non-integer expressions; prepared statements retain their existing fallback where applicable.Validation:
./pkg/sql/planunit suite, normal and-race.go vetand golangci-lint for./pkg/sql/plan.