Repository navigation
fix(planner): merge secondary indexes for OR predicates - #32086
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? |
|
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: 224ce6f830c89e43c7e6fcc4e61ce8d430e1440a
Assessment: approve
The bounded OR access path coherently reuses regular-index safety/cost matching, physical primary keys, global union deduplication and one existing INDEX backfill. Exact branch predicates, residuals, NULL/bag semantics, snapshots, hints and pagination boundaries are preserved; failed construction does not publish partial plans. Existing single-index precedence remains intact. The approved design matches the frozen document, and the added planning/query-local complexity is justified without a new executor or persistent mechanism. No actionable correctness or design defect remains.
Model: gpt-6.1-sol / max
Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0
Validation:
-
All six new planner tests passed with -count=1: 38 cases including subtests, no skips. Named output in index-merge-focused.jsonl proves default selection, fallback/cost controls, composite identity, branch budget and construction rollback.
-
Full pkg/sql/plan passed with -count=1: 4646 top-level cases and 22563 including subcases; two unrelated preexisting subtests skipped. planner-normal.jsonl retains terminal output and exact selection.
-
Nine focused compile/INDEX/group consumer tests passed across three packages, 20 cases including subtests and no skips. They cover global distinct merge, broadcast INDEX ownership, generation reset, allocation recovery, spill cleanup and cancellation. See consumer-focused.jsonl.
-
Preflight, native provenance/current-input verification and frozen-range diff check passed. validation-audit.json reconciles clean-head command receipts, assigned caches/executor, terminal exits, log hashes, both discussion keys and the exact approved design blob.
-
Reviewed the complete SQL case/result against its explicit data and independent IGNORE INDEX controls. Frozen current-head CI reports successful UT, build, SCA and applicable BVT checks; author reports repeated BVT, two-CN execution and the unhinted 200000-row case. Skipped/neutral CI jobs are not counted as validation.
Limitations:
-
Live SQL/BVT and the large-table performance experiment were not rerun locally; author raw artifacts and external CI command logs were not supplied. The reported 401-row/two-index-block result is distinguished from independently reproduced local planner/consumer checks.
-
Full planner validation skipped preexisting HNSW cosine-similarity and interval-frame subcases; changed tests ran without skips.
✅ Merged into
|
…upstream's new buildRegularIndexOnlyScan builder (matrixorigin#32086 split applyRegularIndexOnlyScan into build-then-publish and made the new secondary-index OR merge reuse it), so single-index and OR-merge locking reads both carry locking-read roles; take upstream OR-index merge, bounded backfill work estimates, MinIO range-read bounds, readutil pk-filter changes, incomplete-exponent literals, python SQLAlchemy/numeric-score fixes, ivfpq/cuVS ignored rows, pagination/rollup BVT, HA deployment kit docs and CI shallow clones
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #31863
What this PR does / why we need it:
Add a cost-gated access path for OR predicates across secondary indexes, after existing single-index alternatives. Each branch produces physical primary keys; one distinct union removes overlapping matches. Exact PK-covered queries avoid the base table, while other queries use one existing INDEX join and retain residual predicates.
Candidate discovery is capped at eight branches without DNF expansion. Unsupported branches, unreliable statistics, excessive cardinality, or unfavorable physical costs retain the existing scan path. Preserve NULL and bag semantics, hints, snapshots, and deduplication before pagination. Backfill retains the existing single-CN policy.
Design: approved v1.
Local validation (Go 1.27.1, macOS arm64):
k=3 OR v=10case: scan input reduced from 200,000 rows / 25 blocks to 401 rows / 2 index blocks, with COUNT=401 and no base-table scan. No FORCE INDEX or explicit ANALYZE was needed; overlap/NULL controls matched the scan results.