Repository navigation
fix(plan): restore composite secondary access on 4.2-dev - #31049
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: 6e9eb05dd93eefd868dfd8f5a503b3606391da44
Assessment: request_changes
Reviewed the complete ten-file delta and affected callers. Deferring composite-key lowering within the existing planner owners is reasonable, but the newly enabled backfill path introduces a confirmed SQL planning failure.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
- P1
pkg/sql/plan/apply_indices.go:1625: For t(a INT NOT NULL, id INT NOT NULL, b INT, payload INT, PRIMARY KEY(a,id), UNIQUE KEY uk_ab(a,b)), execute SELECT payload FROM t WHERE a=1 AND b=2 AND id<payload.
Impact: Automatic secondary selection now reaches applyExtraFiltersOnIndex, which rewrites id but leaves the base-table payload reference inside the index scan. Valid SQL fails with a column-remapping error. Push a residual only when all its column references can be mapped to the index; otherwise retain it solely on the base scan.
Evidence: The public SQL reproduction returned error 1064: 'Column remapping failed', missing t.payload in the index TABLE_SCAN FilterList. Identical SQL returned 100 with all four changed production files overlaid from the merge base. Retained sql-check.log and sql-base.log correspond to receipts 1792851509337326834-3.json (exit 1) and 1792851602452049786-4.json (exit 0).
Validation:
-
Verified the clean frozen head, complete patch, freshly built native inputs, base-control overlays, command receipts and retained logs. Evidence mapping: /home/xupeng/.local/state/mo-bot/jobs/814ed2a8187b02b9b15a79b2/attempt-1/review-notes.json.
-
Planner package passed 1,673 top-level tests; all nine focused changed/directly affected tests passed. Package-scoped configured static analysis reported zero issues.
-
Isolated public SQL controls passed for covering/backfill access, prepared NULL/no-match reuse, signed zeros, escaped-NUL strings, joins, composite cluster keys, and update/delete rollback.
-
The 20,004-row generated-column fixture used one secondary row plus one base row for automatic SELECT and FOR UPDATE. A competing update timed out while locked and succeeded after rollback.
-
Measured float fallback cost increased from two input rows to 8,192 on a separate fixture. Accepted as a correctness tradeoff: the merge-base index lookup missed persisted -0 queried as 0, while this candidate returned the correct row.
Limitations:
-
Execution covered Linux amd64 CPU with one embedded CN; distributed BVT and other platforms were not rerun. Frozen CI remained pending.
-
The frozen evidence omitted linked issue #31046's body and supplied no retained author validation receipts. Author timing and race claims were not treated as verified.
-
No universal latency-equivalence claim; broader workload timing remains unmeasured.
|
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: af81158435fe6c6948416de39e08bdb96c1e7b63
Assessment: approve
Reviewed the complete ten-file delta and affected callers. Deferring composite-key lowering preserves logical predicates for index selection, while shared complete-value mapping consistently protects covering scans and residual pushdown. Existing planner owners remain authoritative. The reported remapping and truncated-prefix failures are resolved; no actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Verified clean frozen source, patch correspondence, native build provenance, base overlays, command receipts and retained logs. Evidence mapping: /home/xupeng/.local/state/mo-bot/jobs/2815ae10762563eb3a92daee/attempt-1/validation-audit.json.
-
Full planner package passed 1,677 top-level tests, including all changed regressions. Configured package lint reported zero issues.
-
Public SQL checks passed mixed/nested residuals, covering/backfill access, signed zeros, escaped-NUL strings, joins, composite cluster keys, prepared NULL/no-match reuse, and update/delete rollback.
-
Exact optimizer index_hint BVT passed all 100 statements twice on one service. Fixture cleanup and unchanged global settings were verified after both runs.
-
On the 20,004-row fixture, automatic SELECT and FOR UPDATE reduced base scan input from 10,003 rows at the merge base to one base row plus one index row. A competing update timed out while locked and succeeded after rollback.
-
Corrected process-reuse benchmarks compared nine planning workloads. Sampled nonindexed composite scan/join controls added approximately 5 KB and 6–9 microseconds per plan. This bounded planning cost is accepted alongside the demonstrated execution improvement; performance is not universally unchanged.
Limitations:
-
Execution covered Linux amd64 CPU with one embedded CN. Distributed topology, other platforms and race tests were not rerun; the changed logic is sequential and planner-local. Frozen CI remained pending.
-
The supplied evidence omitted linked issue #31046's body and contained no retained author validation gates. Author execution claims were not treated as verified.
-
Initial mock benchmarks were excluded because repeated process creation distorted measurements; one timed out. Corrected benchmarks completed successfully. Three unrelated existing planner subtests remained skipped.
-
Floating-point lookup fallback can increase scanning to preserve signed-zero correctness. Broader workload and production-concurrency performance remain unmeasured.
|
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: 7f8a751ef69a9dde530f85a139d93cca2a99ae95
Assessment: approve
Reviewed the complete ten-file delta and affected callers. Deferring physical composite-key lowering preserves logical predicates for the existing index ranker without introducing competing state. Shared complete-value mapping closes the prior residual-remapping concern; full-primary preference, hints, pruning and encoding safeguards remain coherent. The measured execution benefit justifies the bounded planning costs. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Verified the frozen head, clean source and matching patch. Command/source/exit receipts, logs, overlays and artifact hashes are reconciled in /home/xupeng/.local/state/mo-bot/jobs/c1aa1c67dd93af1523bd36d7/attempt-1/validation-audit.json; final audit receipt 1792871039046142425-4.json passed.
-
Isolation preflight passed. Reconciled 170 native source inputs and five library hashes with retained repository-owner build evidence.
-
All 1,683 top-level planner tests passed. Configured incremental golangci-lint reported zero issues.
-
Public SQL checks passed for mixed residuals, signed zeros, escaped-NUL strings, temporal OR predicates across time zones, hints, prepared reuse, NULL/no-match cases, rollback and locking.
-
The exact current index-hint BVT passed twice on one service: 125 cases per run, zero failures or skips, with database cleanup and unchanged global settings verified.
-
The 20,004-row workload read 10,003 base rows at the merge base versus one secondary row plus one base row at this head, for both SELECT and SELECT FOR UPDATE. Competing-update timeout and release after rollback passed.
-
Twelve paired planning benchmarks passed. Secondary selection added approximately 15.4 microseconds, 13.3 KB and 137 allocations per plan. Full composite-primary points added 550 bytes and nine allocations; ordinary nonindexed scan/join and UPDATE/DELETE/CREATE allocation counts were unchanged.
Limitations:
-
Runtime validation used Linux amd64 and a local single-CN deployment. Distributed, race and other-platform suites were not rerun; frozen remote CI was still pending.
-
Three preexisting nested planner subtests skipped. The linked issue #31046 body was absent from supplied evidence; its contract was assessed through the PR, design document and supplied concerns.
-
Three-sample microbenchmarks do not establish production latency or concurrency guarantees. The unflushed workload demonstrates reduced input rows, not durable-object I/O savings.
|
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: 8b412d0f278644758469b94a3afae18869392b78
Assessment: approve
Reviewed the complete 17-file delta and affected callers. Deferring physical key lowering preserves logical predicates for existing index selection; shared column mapping protects covering scans and residual pushdown. The earlier remapping concern is resolved. The design and measured costs are reasonable, with no actionable findings remaining.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
Validation:
-
Verified clean frozen source, patch correspondence, native provenance, overlays, commands, exit receipts and logs. Evidence: /home/xupeng/.local/state/mo-bot/jobs/6f13e135dd3b368b9a164fce/attempt-1/validation-audit.json.
-
Isolation preflight passed. Reconciled 170 native source inputs and five library hashes with a successful repository-owner build.
-
All 1,683 top-level planner tests passed, including 17 explicitly checked focused tests. Package build, configured incremental lint and formatting checks passed.
-
Public SQL checks passed covering/backfill access, mixed residuals, signed zeros, escaped-NUL strings, temporal comparisons, hints, prepared reuse, NULL/no-match cases, rollback and locking.
-
Five affected SQL regression files passed twice on one service: 427 statements per run, zero failures or ignored statements; cleanup and unchanged global settings verified.
-
The 20,004-row fixture read 10,003 base rows at the merge base versus one base row plus one index row at this head, for SELECT and SELECT FOR UPDATE. Competing-update timeout and release after rollback passed.
-
Twelve paired planning benchmarks passed. Secondary selection added approximately 12 microseconds, 13.3 KB and 137 allocations per plan. Full composite-primary points added 550 bytes and nine allocations; ordinary scan/join and UPDATE/DELETE/CREATE allocation counts were unchanged.
-
Final audit receipt 1792875837207766304-3.json passed. The initial audit mismatch was solely the supplied patch's omitted final newline.
Limitations:
-
Runtime validation covered Linux amd64 CPU with one CN; distributed topology, other platforms and race suites were not rerun. Changed logic is sequential and planner-local.
-
Three nested planner tests skipped. Frozen CI remained incomplete; unsupported author validation claims were not counted.
-
Linked issue #31046's body was absent; its contract was assessed through the supplied PR, design document and regression concerns.
-
Floating-point fallback may increase scanning to preserve correctness. Microbenchmarks and the unflushed fixture do not establish durable-object I/O savings or production-concurrency latency.
What type of PR is this?
Which issue(s) this PR fixes:
Related to #31046
What this PR does / why we need it:
Fix the composite-key predicate phase and primary-prefix/default-statistics preferences on 4.2-dev using its existing selectivity ranker. Complete eligible UNIQUE points use their one-row bound; unknown candidates retain the existing small-table policy with bounded UNIQUE priority.
Ensure residual predicates are pushed only when every column reference can be mapped to the index scan. Covering and backfill paths share the existing regular-index mapping; mixed index/base-column predicates such as
id < payloadstay on the base scan instead of producingColumn remapping failed. Preserve the whole base predicate and avoid duplicating volatile or unsupported expressions. Both covering paths reuse the same complete-value map: truncated prefix-index parts cannot supply base-column values, so projections and residuals requiring them use backfill; full stored PK values remain usable. Mapping is bounded by index/primary-key parts and is constructed lazily; the no-extra-filter path remains allocation-free.Close newly reachable encoding errors in the existing eligibility/residual owners: floating-point predicates cannot use physical serialized comparisons that distinguish signed zeros, and covering string-prefix lookups retain exact decoded predicates for escaped-NUL peers. Exact rechecks do not count selectivity twice. No storage, protocol or executor format changes.
FLOAT/DOUBLE predicates remain excluded from serialized regular-index access, including finite nonzero comparisons. Queries that previously relied on that access may scan the base table and read more rows, increasing I/O and latency; eligible predicates on other index parts can still provide access while the float predicate remains an exact residual. This correctness fallback is not a cast optimization or a universal no-regression claim.
Preserve OR-to-IN normalization before index matching while deferring only physical compound-key lowering. Complete equality on a physically ordered real primary key is checked without allocation before secondary candidates are constructed; FORCE INDEX still bypasses the automatic preference. Reuse the existing collector for phase-specific pruning snapshots, retain snapshots for already-lowered scans, and skip redundant late work on nondeferred queries. The pre-existing statistics refresh remains unconditional.
Final local validation (Go 1.26.4, macOS ARM64): the entire
pkg/sql/planpackage passes normal and-race -count=1tests (1,683 top-level tests); canonical service build and incremental configured SCA pass. Configured golangci-lint reports no new issues; the three existing molint recover advisories are unchanged. The optimizer index-hint BVT passes twice on the same service with cleanup verified. The four affected legacy BVTs also pass all 302 statements, followed by the entire optimizer directory on the same service: 29 cases / 1,384 statements, 1,371 successful, zero failures or abnormal results, and 13 existing ignored statements. All 106 existing SELECT result blocks are preserved. Added literal-row checks cover FLOAT32 signed zeros, automatic/FORCE/IGNORE, prepared 9 → 0 → NULL → 0 reuse, and escaped-NUL CHAR/LIKE peers. EXPLAIN expectations are updated only for the verified access and residual changes; the float fallback assertion also checks the base scan, raw-column predicate and absence of a column cast. Public checks retain the prior residual/prefix-value coverage and add OR/IN, automatic/FORCE/IGNORE, full primary points, prepared reuse/NULL/no-match, cluster/join, rollback and competing FOR UPDATE conflict/release.Paired planner microbenchmarks use the same reused-process fixtures. Allocation counts, base / previous PR head / fixed:
id=1: 439 / 441 / 438;id=1 AND a=1 AND b=1: 619 / 744 / 618. Nonindexed composite PK/cluster controls match base. Complete composite-PK points improve from 668 to 641 allocations, versus base 632 (remaining ~0.6 KB); paired base/fixed medians were 26.35 / 27.40 µs. Indexed-prefix queries now perform useful secondary-index selection rather than the old incorrect prefix shortcut. These bounded costs are disclosed; this is not a universal zero-planning-overhead claim.The original unflushed 20,004-row fixture still reads one secondary row plus one base row in all automatic/FORCE and plain/FOR UPDATE variants, instead of 10,004 base rows. These are local single-CN checks; remote CI and distributed-platform validation remain pending.
Design and final overall review use explicitly selected
gpt-6.1-solwithxhighreasoning.