Repository navigation
fix(plan): always consider usable indexes - #26972
Merged
Merged
Conversation
Remove index visibility from optimizer candidate eligibility across regular, fulltext, vector, join, and hint paths. Retain legacy catalog and DDL metadata for compatibility, reserve the removed protobuf wire identity, and keep the consumed upgrade offset stable.
XuPeng-SH
requested review from
LeftHandCold,
aptend,
aunjgr and
fengttt
as code owners
August 11, 2026 16:03
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? |
fengttt
approved these changes
Aug 11, 2026
XuPeng-SH
added a commit
that referenced
this pull request
Aug 12, 2026
Follow-up to #26972. Removing the nil-tolerant optimizer visibility filter exposed unchecked nil IndexDef dereferences, but blindly skipping nil metadata on every path is not correct. ## Invariant and failure policy Persisted engine metadata is dense: protobuf and constraint decoders allocate an IndexDef for every stored entry. A nil entry therefore represents incomplete in-memory metadata, not an optional physical index. - read-only discovery and display paths skip nil entries and keep processing later valid indexes; the base table remains the authoritative correctness fallback - mutation, locking, clone, and index-lifecycle paths fail closed before an unknown index can be omitted from maintenance, locking, copy, truncate, rename, or drop work - no metadata is compacted, guessed, repaired in the background, or silently normalized ## What changed Read-only closure: - master, regular join, vector single-row, SHOW CREATE, SHOW COLUMNS, PREPARE dependency, and index-size traversals tolerate nil entries - later valid indexes and plugin hidden-table dependencies remain eligible Mutation closure: - one dense-metadata validator is applied at the common DML target boundary - ALTER, RENAME, TRUNCATE, DROP TABLE, CREATE/DROP INDEX, CREATE TABLE LIKE/CLONE, and foreign-key creation validate before lifecycle work - SELECT FOR UPDATE/SHARE validates before hidden-index lock planning - foreign-key unique-parent locking and cascaded child mutations validate related table metadata before building their mutation work ## Compatibility The 4.1-dev and 4.2-dev visibility compatibility surface remains unchanged: protobuf field 8, mo_indexes.is_visible, accepted VISIBLE/INVISIBLE syntax, ALTER behavior, and SHOW behavior are preserved. Field 14 remains reserved as established by #26972. No wire, catalog, migration, or persisted metadata changes are introduced. ## Performance and unhappy paths Read-only traversals add one constant-time nil branch per visited index. Mutation validation is a bounded O(number of indexes) planner-time scan per resolved table boundary, with no allocations on the healthy path. There is no row-level or batch-level work, catalog I/O, logging, retry loop, background task, cache, or new resource ownership. Invalid metadata returns one deterministic internal error. It is not logged repeatedly and cannot proceed far enough to create index divergence or orphan hidden tables. ## Validation - deterministic RED reproductions for SHOW COLUMNS, SELECT FOR UPDATE, DML/DDL mutation paths, foreign-key unique-parent locking, and cascade-child mutation - regressions for nil-before-valid filter, join, vector, SHOW CREATE/COLUMNS, PREPARE, and plugin dependency paths - INSERT, LOAD, REPLACE, UPDATE, DELETE, ALTER, RENAME, TRUNCATE, DROP, CREATE/DROP INDEX, CREATE LIKE, and CLONE fail-closed matrix - full pkg/sql/plan tests - go list, go build, and go vet for pkg/sql/plan - git diff --check - rebased onto current main at 3f2ed9b
cpegeric
added a commit
to cpegeric/matrixone
that referenced
this pull request
Aug 12, 2026
Conflicts in pkg/sql/plan/apply_indices_fulltext.go and build_ddl.go: main's matrixorigin#26972 removes optimizer index-visibility gating (catalog.IsIndexOptimizerEligible, setIndexDefsVisibility, and pkg/catalog/index_visibility.go are deleted), while this branch had restructured the same lines for fulltext2. Resolved by keeping the branch's fulltext2 storage-def selection and BuildSessionVars capture, and taking main's removal of both visibility calls. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
## What changed Index visibility no longer participates in optimizer candidate eligibility. Every physically present, semantically applicable index is considered; the cost model and explicit index hints decide whether it is used. This removes the visibility gating introduced by matrixorigin#26881 across: - regular, master, and spatial index discovery - fulltext index matching - vector direct-scan and logical multi-table index discovery - join and index-hint paths It also removes the visibility initialization helper, propagation, and per-tenant reconciliation migration added by that PR. ## Compatibility boundary The historical `IndexDef.visible` field, `mo_indexes.is_visible` column, and accepted DDL syntax remain compatibility metadata only. They are not optimizer switches. - protobuf field 14 / `visibility_set` is removed and reserved, so its published wire identity cannot be reused - old field-14 data is accepted and preserved as unknown wire data - the consumed v4.0.6 upgrade offset remains reserved; persisted upgrade identity never moves backward - no catalog-wide normalization scan or ALTER replay is added Nil `IndexDef` entries remain safely skipped after removing the old nil-tolerant visibility helper. ## Performance The planner hot paths remove visibility helper calls, vector visibility tracking maps, and candidate-filter slice allocation. There is no new scan, I/O, logging, cache, or background maintenance. ## Validation - focused visibility, hint, regular-index, fulltext, vector, protobuf compatibility, catalog metadata, and upgrade-offset regressions - full owning-package tests: - `./pkg/bootstrap/versions/v4_0_6` - `./pkg/publication` - `./pkg/sql/colexec` - `./pkg/sql/compile` - `./pkg/sql/plan` - `go vet` on the same owning packages - protobuf regenerated; `git diff --check`
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
Follow-up to matrixorigin#26972. Removing the nil-tolerant optimizer visibility filter exposed unchecked nil IndexDef dereferences, but blindly skipping nil metadata on every path is not correct. ## Invariant and failure policy Persisted engine metadata is dense: protobuf and constraint decoders allocate an IndexDef for every stored entry. A nil entry therefore represents incomplete in-memory metadata, not an optional physical index. - read-only discovery and display paths skip nil entries and keep processing later valid indexes; the base table remains the authoritative correctness fallback - mutation, locking, clone, and index-lifecycle paths fail closed before an unknown index can be omitted from maintenance, locking, copy, truncate, rename, or drop work - no metadata is compacted, guessed, repaired in the background, or silently normalized ## What changed Read-only closure: - master, regular join, vector single-row, SHOW CREATE, SHOW COLUMNS, PREPARE dependency, and index-size traversals tolerate nil entries - later valid indexes and plugin hidden-table dependencies remain eligible Mutation closure: - one dense-metadata validator is applied at the common DML target boundary - ALTER, RENAME, TRUNCATE, DROP TABLE, CREATE/DROP INDEX, CREATE TABLE LIKE/CLONE, and foreign-key creation validate before lifecycle work - SELECT FOR UPDATE/SHARE validates before hidden-index lock planning - foreign-key unique-parent locking and cascaded child mutations validate related table metadata before building their mutation work ## Compatibility The 4.1-dev and 4.2-dev visibility compatibility surface remains unchanged: protobuf field 8, mo_indexes.is_visible, accepted VISIBLE/INVISIBLE syntax, ALTER behavior, and SHOW behavior are preserved. Field 14 remains reserved as established by matrixorigin#26972. No wire, catalog, migration, or persisted metadata changes are introduced. ## Performance and unhappy paths Read-only traversals add one constant-time nil branch per visited index. Mutation validation is a bounded O(number of indexes) planner-time scan per resolved table boundary, with no allocations on the healthy path. There is no row-level or batch-level work, catalog I/O, logging, retry loop, background task, cache, or new resource ownership. Invalid metadata returns one deterministic internal error. It is not logged repeatedly and cannot proceed far enough to create index divergence or orphan hidden tables. ## Validation - deterministic RED reproductions for SHOW COLUMNS, SELECT FOR UPDATE, DML/DDL mutation paths, foreign-key unique-parent locking, and cascade-child mutation - regressions for nil-before-valid filter, join, vector, SHOW CREATE/COLUMNS, PREPARE, and plugin dependency paths - INSERT, LOAD, REPLACE, UPDATE, DELETE, ALTER, RENAME, TRUNCATE, DROP, CREATE/DROP INDEX, CREATE LIKE, and CLONE fail-closed matrix - full pkg/sql/plan tests - go list, go build, and go vet for pkg/sql/plan - git diff --check - rebased onto current main at 3f2ed9b
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
## What changed Index visibility no longer participates in optimizer candidate eligibility. Every physically present, semantically applicable index is considered; the cost model and explicit index hints decide whether it is used. This removes the visibility gating introduced by matrixorigin#26881 across: - regular, master, and spatial index discovery - fulltext index matching - vector direct-scan and logical multi-table index discovery - join and index-hint paths It also removes the visibility initialization helper, propagation, and per-tenant reconciliation migration added by that PR. ## Compatibility boundary The historical `IndexDef.visible` field, `mo_indexes.is_visible` column, and accepted DDL syntax remain compatibility metadata only. They are not optimizer switches. - protobuf field 14 / `visibility_set` is removed and reserved, so its published wire identity cannot be reused - old field-14 data is accepted and preserved as unknown wire data - the consumed v4.0.6 upgrade offset remains reserved; persisted upgrade identity never moves backward - no catalog-wide normalization scan or ALTER replay is added Nil `IndexDef` entries remain safely skipped after removing the old nil-tolerant visibility helper. ## Performance The planner hot paths remove visibility helper calls, vector visibility tracking maps, and candidate-filter slice allocation. There is no new scan, I/O, logging, cache, or background maintenance. ## Validation - focused visibility, hint, regular-index, fulltext, vector, protobuf compatibility, catalog metadata, and upgrade-offset regressions - full owning-package tests: - `./pkg/bootstrap/versions/v4_0_6` - `./pkg/publication` - `./pkg/sql/colexec` - `./pkg/sql/compile` - `./pkg/sql/plan` - `go vet` on the same owning packages - protobuf regenerated; `git diff --check`
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
Follow-up to matrixorigin#26972. Removing the nil-tolerant optimizer visibility filter exposed unchecked nil IndexDef dereferences, but blindly skipping nil metadata on every path is not correct. ## Invariant and failure policy Persisted engine metadata is dense: protobuf and constraint decoders allocate an IndexDef for every stored entry. A nil entry therefore represents incomplete in-memory metadata, not an optional physical index. - read-only discovery and display paths skip nil entries and keep processing later valid indexes; the base table remains the authoritative correctness fallback - mutation, locking, clone, and index-lifecycle paths fail closed before an unknown index can be omitted from maintenance, locking, copy, truncate, rename, or drop work - no metadata is compacted, guessed, repaired in the background, or silently normalized ## What changed Read-only closure: - master, regular join, vector single-row, SHOW CREATE, SHOW COLUMNS, PREPARE dependency, and index-size traversals tolerate nil entries - later valid indexes and plugin hidden-table dependencies remain eligible Mutation closure: - one dense-metadata validator is applied at the common DML target boundary - ALTER, RENAME, TRUNCATE, DROP TABLE, CREATE/DROP INDEX, CREATE TABLE LIKE/CLONE, and foreign-key creation validate before lifecycle work - SELECT FOR UPDATE/SHARE validates before hidden-index lock planning - foreign-key unique-parent locking and cascaded child mutations validate related table metadata before building their mutation work ## Compatibility The 4.1-dev and 4.2-dev visibility compatibility surface remains unchanged: protobuf field 8, mo_indexes.is_visible, accepted VISIBLE/INVISIBLE syntax, ALTER behavior, and SHOW behavior are preserved. Field 14 remains reserved as established by matrixorigin#26972. No wire, catalog, migration, or persisted metadata changes are introduced. ## Performance and unhappy paths Read-only traversals add one constant-time nil branch per visited index. Mutation validation is a bounded O(number of indexes) planner-time scan per resolved table boundary, with no allocations on the healthy path. There is no row-level or batch-level work, catalog I/O, logging, retry loop, background task, cache, or new resource ownership. Invalid metadata returns one deterministic internal error. It is not logged repeatedly and cannot proceed far enough to create index divergence or orphan hidden tables. ## Validation - deterministic RED reproductions for SHOW COLUMNS, SELECT FOR UPDATE, DML/DDL mutation paths, foreign-key unique-parent locking, and cascade-child mutation - regressions for nil-before-valid filter, join, vector, SHOW CREATE/COLUMNS, PREPARE, and plugin dependency paths - INSERT, LOAD, REPLACE, UPDATE, DELETE, ALTER, RENAME, TRUNCATE, DROP, CREATE/DROP INDEX, CREATE LIKE, and CLONE fail-closed matrix - full pkg/sql/plan tests - go list, go build, and go vet for pkg/sql/plan - git diff --check - rebased onto current main at 3f2ed9b
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
## What changed Index visibility no longer participates in optimizer candidate eligibility. Every physically present, semantically applicable index is considered; the cost model and explicit index hints decide whether it is used. This removes the visibility gating introduced by matrixorigin#26881 across: - regular, master, and spatial index discovery - fulltext index matching - vector direct-scan and logical multi-table index discovery - join and index-hint paths It also removes the visibility initialization helper, propagation, and per-tenant reconciliation migration added by that PR. ## Compatibility boundary The historical `IndexDef.visible` field, `mo_indexes.is_visible` column, and accepted DDL syntax remain compatibility metadata only. They are not optimizer switches. - protobuf field 14 / `visibility_set` is removed and reserved, so its published wire identity cannot be reused - old field-14 data is accepted and preserved as unknown wire data - the consumed v4.0.6 upgrade offset remains reserved; persisted upgrade identity never moves backward - no catalog-wide normalization scan or ALTER replay is added Nil `IndexDef` entries remain safely skipped after removing the old nil-tolerant visibility helper. ## Performance The planner hot paths remove visibility helper calls, vector visibility tracking maps, and candidate-filter slice allocation. There is no new scan, I/O, logging, cache, or background maintenance. ## Validation - focused visibility, hint, regular-index, fulltext, vector, protobuf compatibility, catalog metadata, and upgrade-offset regressions - full owning-package tests: - `./pkg/bootstrap/versions/v4_0_6` - `./pkg/publication` - `./pkg/sql/colexec` - `./pkg/sql/compile` - `./pkg/sql/plan` - `go vet` on the same owning packages - protobuf regenerated; `git diff --check`
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
Follow-up to matrixorigin#26972. Removing the nil-tolerant optimizer visibility filter exposed unchecked nil IndexDef dereferences, but blindly skipping nil metadata on every path is not correct. ## Invariant and failure policy Persisted engine metadata is dense: protobuf and constraint decoders allocate an IndexDef for every stored entry. A nil entry therefore represents incomplete in-memory metadata, not an optional physical index. - read-only discovery and display paths skip nil entries and keep processing later valid indexes; the base table remains the authoritative correctness fallback - mutation, locking, clone, and index-lifecycle paths fail closed before an unknown index can be omitted from maintenance, locking, copy, truncate, rename, or drop work - no metadata is compacted, guessed, repaired in the background, or silently normalized ## What changed Read-only closure: - master, regular join, vector single-row, SHOW CREATE, SHOW COLUMNS, PREPARE dependency, and index-size traversals tolerate nil entries - later valid indexes and plugin hidden-table dependencies remain eligible Mutation closure: - one dense-metadata validator is applied at the common DML target boundary - ALTER, RENAME, TRUNCATE, DROP TABLE, CREATE/DROP INDEX, CREATE TABLE LIKE/CLONE, and foreign-key creation validate before lifecycle work - SELECT FOR UPDATE/SHARE validates before hidden-index lock planning - foreign-key unique-parent locking and cascaded child mutations validate related table metadata before building their mutation work ## Compatibility The 4.1-dev and 4.2-dev visibility compatibility surface remains unchanged: protobuf field 8, mo_indexes.is_visible, accepted VISIBLE/INVISIBLE syntax, ALTER behavior, and SHOW behavior are preserved. Field 14 remains reserved as established by matrixorigin#26972. No wire, catalog, migration, or persisted metadata changes are introduced. ## Performance and unhappy paths Read-only traversals add one constant-time nil branch per visited index. Mutation validation is a bounded O(number of indexes) planner-time scan per resolved table boundary, with no allocations on the healthy path. There is no row-level or batch-level work, catalog I/O, logging, retry loop, background task, cache, or new resource ownership. Invalid metadata returns one deterministic internal error. It is not logged repeatedly and cannot proceed far enough to create index divergence or orphan hidden tables. ## Validation - deterministic RED reproductions for SHOW COLUMNS, SELECT FOR UPDATE, DML/DDL mutation paths, foreign-key unique-parent locking, and cascade-child mutation - regressions for nil-before-valid filter, join, vector, SHOW CREATE/COLUMNS, PREPARE, and plugin dependency paths - INSERT, LOAD, REPLACE, UPDATE, DELETE, ALTER, RENAME, TRUNCATE, DROP, CREATE/DROP INDEX, CREATE LIKE, and CLONE fail-closed matrix - full pkg/sql/plan tests - go list, go build, and go vet for pkg/sql/plan - git diff --check - rebased onto current main at 3f2ed9b
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Index visibility no longer participates in optimizer candidate eligibility. Every physically present, semantically applicable index is considered; the cost model and explicit index hints decide whether it is used.
This removes the visibility gating introduced by #26881 across:
It also removes the visibility initialization helper, propagation, and per-tenant reconciliation migration added by that PR.
Compatibility boundary
The historical
IndexDef.visiblefield,mo_indexes.is_visiblecolumn, and accepted DDL syntax remain compatibility metadata only. They are not optimizer switches.visibility_setis removed and reserved, so its published wire identity cannot be reusedNil
IndexDefentries remain safely skipped after removing the old nil-tolerant visibility helper.Performance
The planner hot paths remove visibility helper calls, vector visibility tracking maps, and candidate-filter slice allocation. There is no new scan, I/O, logging, cache, or background maintenance.
Validation
./pkg/bootstrap/versions/v4_0_6./pkg/publication./pkg/sql/colexec./pkg/sql/compile./pkg/sql/plango veton the same owning packagesgit diff --check