Repository navigation
perf(plan): cost bounded DELETE lookups using index cardinality - #33044
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: dbd549f94fabf7d8262a38ae22754815474237c7
Assessment: approve
The late DELETE retry now uses known index cardinality to avoid rejecting selective full-primary-key lookups when sampled NDV is too low. It reuses the existing runtime filter path and preserves the strict 10% cutoff, key budget, and single-CN placement checks.
Model: gpt-6.2-sol / xhigh
Session: 01a1ee80-0d82-7030-a965-b51f496c3054 · slot 2 · generation 1
Validation:
-
Verified the frozen patch, pinned policy, native inputs, and isolation preflight. Reconciled all three discussion entries and matched the retained logs to their receipts in validation-reconciliation.json.
-
Focused planner and HashBuild tests passed under race, including the exact 10% cutoff, unknown cardinality, forced distribution, and runtime memory fallback. See focused-race.stdout and receipt 1795274992324677592-2.
-
With only runtime_filter.go replaced by its pinned-base version, the same SQL planner test failed at the expected missing index probe assertion. See base-control.stdout and receipt 1795274988710994011-2.
Limitations:
- The scan reduction, deletion count, and rollback results come from the author's controlled SQL comparison. Local execution covered planner and HashBuild tests.
Independent QA challenge: not passing yetI ran new probes against base f1ffbaa and head dbd549f. Existing unit tests were not used as QA evidence.
The measured latency difference must not be interpreted as a confirmed regression: the changed path was not reached in either binary. Conversely, this workload cannot support a performance-improvement claim. Every measured DELETE affected 1,000 rows and rollback restored 100,000 rows, but that does not validate execution through the newly admitted filter path. Before QA sign-off, please provide a real SQL workload whose EXPLAIN ANALYZE confirms the intended full-index-PK runtime filter on head, then rerun the base/head performance comparison and end-to-end DELETE correctness checks through that path. The unknown-cardinality control was not executed in this SQL workload. |
|
mo-bot review · Commit: New discussion was assessed; the previous review remains unchanged. |
Corrected independent SQL QA: PASS for the original issue workloadThis supersedes my earlier QA comment. The earlier SQL results were invalid because port 6001 was already occupied by a Docker MatrixOne instance (v4.2.8, git 10d204b), so the workload was not executed by the base/head binaries. I apologize for that incorrect conclusion. I rebuilt and reran the base/head processes on an isolated port, using the original #31618 candidate schema and history. No existing unit tests were used as QA evidence. Workload:
Head reduced median latency by approximately 37.2% and mean latency by approximately 38.6%, while reducing the target scan from 98,000 rows to 1,000 rows. Correctness checks passed in every measured run: exactly 1,000 rows were deleted, 97,000 rows remained before rollback, and rollback restored 98,000 rows. The unknown-cardinality control also behaved conservatively: with table_cnt=0, both base and head omitted the target runtime filter and scanned 98,000 rows / 12 blocks. Conclusion: performance and SQL DELETE/rollback correctness pass for this original issue workload. This conclusion is scoped to the exercised path and controls. |
What type of PR is this?
Which issue(s) this PR fixes:
Related to #31618. Builds on #31738.
What this PR does / why we need it:
A bounded DELETE still falls back to scanning a hidden index when sampled NDV underestimates the cardinality of its full primary key. In the regression fixture, a 1,000-key bound is selective against a 97,000-row index but hits the previous cost cutoff with an NDV of 1,000.
For the existing late runtime filter path, use known index row count as a lower bound on the NDV estimate when the match is on the complete stored primary key. Each exact lookup key can match at most one visible index row. The 10% selectivity cutoff, key and allocation budgets, index eligibility, join direction, and independent single-CN placement proof still apply.
Validation