Skip to content

[4.2-dev] Preserve block selectivity for prepared IN lookups - #32983

Merged
XuPeng-SH merged 3 commits into
matrixorigin:4.2-devfrom
iamlinjunhong:codex/32965-prepared-in
Nov 20, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:4.2-devfrom
iamlinjunhong:codex/32965-prepared-in

Conversation

@iamlinjunhong

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #32965

What this PR does / why we need it:

Prepared secondary-index lookups such as k IN (?, …, ?) keep their parameters in an expression list. The column-reference check rejected this list, which inflated the estimated number of index blocks and classified the lookup as AP. This prevented reuse of its prepare-time physical compilation.

Accept a nonempty list when every element is constant at execution time. Keep rejecting column-bearing lists because predicate substitution does not rewrite their contents. Add regression coverage for nested column references and for the execution type of prepared and literal lookups on a non-covering secondary index.

Validated on Linux with the full race-enabled unit suite, the additional catalog package, planner vet and incremental lint. The full standalone SQL suite in UTC passed all 108,941 active checks across 1,286 scripts (1,102 marked ignored). In a same-host 1,000-thread sysbench replay (one five-minute measurement per revision), throughput rose from 1,658 to 2,786 TPS and p95 fell from 1,352 to 847 ms. The pre-regression revision reached 2,720 TPS. All three runs returned identical rows for a fixed parameter set and reported zero execution errors.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code change looks sound to me. It restores prepared IN-list block selectivity through the existing runtime-constant predicate, while retaining the conservative rejection of lists containing column references. The same helper also serves join-filter deduction, so I checked that substituteMatchColumn does not need to rewrite anything inside the newly admitted lists. I did not find a correctness, design, or performance blocker in this change. There were no prior substantive review comments on this PR.

Validation on 81cd749d7848:

  • The focused planner tests passed, including the new non-covering index / execution-type test and the empty, same-column, and other-column list cases. With only utils.go overlaid from the exact base, the new prepared-IN planner test failed as expected: it classified the parameter-list query as AP rather than TP.
  • An independent embedded-cluster MySQL-protocol probe exercised a prepared non-covering secondary-index lookup repeatedly with changing values, duplicates, NULLs, and misses, and checked join results with both a parameter list and a list containing a column. All expected rows matched. This checks result behavior; it is not a replacement for the author's large-table throughput measurement.
  • The two TestIssue32820*RestoreReconstructsAlterAncestorLineage assertions that failed in the first Ubuntu UT run passed when rerun in isolation on this head.

CI qualification: the first required Ubuntu UT run failed in multiple tests, including widespread cluster timeouts and the two restore assertions above. The isolated passes do not establish the cause of every CI failure. I restarted the failed checks; their result is still pending, so the required CI gate must pass or the remaining failures must be independently explained before merge. The author's end-to-end performance figures are single-run measurements and were not independently rerun on the original benchmark host.

@mergify mergify Bot added the queued label Nov 20, 2026
@mergify

mergify Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

❌ Left the queue · Matrixone Coverage execution / Coverage fails with this pull request

50 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Fri 20 Nov, 09:13 · rule release-4.2 · triggered by rule Automatic queue on approval for release-4.2
  • ❌ Checks failed · in place
  • 🚫 Left the queue 10:03 · 207fc95

The failure is in this pull request. It failed tested alone on top of 4.2-dev.

Reason

The merge conditions cannot be satisfied due to failing checks

  • CI Required

Failing checks:

To get back in the queue

  • Push a fix: the pull request is queued again once its queue conditions match.
  • If the failure is a flake, tick the box below to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = CI Required
    • check-skipped = CI Required
    • check-success = CI Required

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request
2 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — 207fc957 Deployed Nov 20, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants