Skip to content

fix(plan): honor invisible indexes in optimizer - #26881

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
XuPeng-SH:agent/fix-invisible-index-26862
Aug 10, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
XuPeng-SH:agent/fix-invisible-index-26862

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

Fixes #26862.

Invisible indexes are physical/constraint metadata, not optimizer candidates. This change introduces an explicit visibility-initialized marker so legacy proto3 defaults remain visible after upgrade, then enforces eligibility across regular, master, spatial, fulltext, vector, join, and index-hint paths.

It preserves index maintenance and unique enforcement, persists visibility through CREATE/ALTER, mo_indexes metadata, deep-copy and SHOW CREATE/restore, and fixes publication DDL visibility default handling.

Validation:

  • pkg/sql/plan
  • pkg/sql/compile
  • pkg/sql/colexec
  • pkg/publication
  • pkg/catalog
  • pkg/vm/engine

@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 →

@fengttt fengttt 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.

WAIT. WHY would not consider using these invisible indices? If it is available, why not use it?

Treat index visibility as optimizer eligibility without changing physical index maintenance or uniqueness semantics. Persist an explicit visibility marker for upgrade-safe legacy defaults, filter every index rewrite path, reject invisible hints, and preserve the state through metadata and SHOW CREATE.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re-reviewed the exact current head cd0e9dd after the latest rebase. Verdict: no remaining merge blocker found. GitHub does not allow the PR author account to submit an approval, so this is recorded as a review comment.

Range-diff against the previously approved head 89d034f shows no semantic change in the four PR commits; the only context shift is in apply_indices_test.go after integrating the encoded regular-index cost work.

I rechecked the complete visibility lifecycle: legacy metadata reconciliation, CREATE/ALTER persistence, protobuf/deep-copy compatibility, mo_indexes, SHOW CREATE and publication DDL, optimizer eligibility across master/regular/spatial/fulltext/vector/join/hint paths, and the intentionally unchanged maintenance and uniqueness paths. The previous publication ADD INVISIBLE blocker remains closed.

Focused changed tests, all eight owning packages, build, vet, protobuf regeneration, diff checks, and index-plugin dispatch guards pass. The latest main merge is conflict-free and its remaining production changes are isolated to timewin.

@XuPeng-SH
XuPeng-SH merged commit 6042ca6 into matrixorigin:main Aug 10, 2026
22 of 25 checks passed

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Optimizer still uses indexes marked INVISIBLE

4 participants