You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Optimizer still uses indexes marked INVISIBLE #26862
Local standalone mo-service (1 CN / 1 TN / 1 Log service), MySQL text protocol.
Reproduction
createdatabaserepro;
use repro;
createtablet(id intprimary key, a int, key idx_a(a));
insert into t select result, result from generate_series(1,10000) g;
altertable t alter index idx_a invisible;
show index from t;
explain select*from t where a=5000;
Actual result
SHOW INDEX correctly reports idx_a as Visible = NO, but EXPLAIN still selects it:
Project
-> Index Table Scan on t.idx_a
Filter Cond: prefix_eq(__mo_index_idx_col)
Reproduced on three independent tables from a new client connection. The invisible plan choice also persists after a full service restart, so it is not a stale session plan cache.
Invisible UNIQUE indexes correctly continue enforcing uniqueness; the issue is optimizer eligibility, not index maintenance.
Expected result
The optimizer should not select an invisible index by default. Making it visible again should restore its eligibility.
Suspected cause
ALTER updates IndexDef.Visible/mo_indexes.is_visible, but the query planner's index-selection paths do not appear to inspect the visibility flag.
Topology: local standalone mo-service with 1 CN, 1 TN, and 1 Log service; MySQL text protocol.
Not covered: multi-CN deployment, restart persistence, and external MySQL execution.
Reproduction Result
Original scenario: Still reproducible.
Evidence: after ALTER TABLE t ALTER INDEX idx_a INVISIBLE, SHOW INDEX reported Visible=NO, but EXPLAIN SELECT * FROM
t WHERE a=50 still contained Index Table Scan on t.idx_a.
Query result: the selective lookup correctly returned row (5,50,'five'), but it used the invisible index.
Reproduction frequency: reproduced in the local standalone verification.
Expected behavior: an invisible secondary index must be excluded from normal optimizer candidates; making it visible
again should restore eligibility.
Findings
The related fix is merged into the verified MatrixOne version: Yes.
Current behavior: index visibility metadata is persisted correctly, but the optimizer still selects the invisible
secondary index.
Unrelated noise: invisible UNIQUE index enforcement remains correct; duplicate insertion returned ERROR 1062. This
is expected maintenance behavior and does not resolve the optimizer eligibility defect.
Reopening: this reproduces again on current main (3ad9adbb4c, 2026-10-22) with the exact SQL from the original report.
createdatabaserepro; use repro;
createtablet(id intprimary key, a int, key idx_a(a));
insert into t select result, result from generate_series(1,10000) g;
altertable t alter index idx_a invisible;
show index from t;
SHOW INDEX reports Visible = NO for idx_a:
t | 0 | PRIMARY | 1 | id | A | ... | YES | id
t | 1 | idx_a | 1 | a | A | ... | NO | a
information_schema.statistics.is_visible also returns NO. The planner nevertheless keeps it:
Project
-> Index Table Scan on t.idx_a
Filter Cond: prefix_eq(__mo_index_idx_col)
Two additional data points:
create index idx_b on t(a) invisible behaves identically — explain select * from t where a=5000 plans Index Table Scan on t.idx_b, so it is not specific to the ALTER INDEX ... INVISIBLE path.
After a full service restart the catalog still reports is_visible = NO and the plan still uses idx_b, so this is not a stale session or plan cache.
White-box: the only consumers of index visibility in the planner are pkg/sql/plan/build_show_util.go:292/372/450 — i.e. the SHOW rendering path. Nothing in index selection (apply_indices.go / query_builder.go) filters candidates by IndexOption_Visibility, which matches the observed behaviour: the flag is stored, reported, and ignored when choosing an access path.
Closing again — I reopened this by mistake. Maintainers confirm that invisible indexes being metadata-only in MatrixOne is an intentional design decision, not a defect: INVISIBLE is reported by SHOW INDEX / information_schema.statistics and does not filter optimizer access-path candidates. The behaviour I observed is therefore expected, and the planner-side opt-in was tracked separately in #26947.
My measurements above stand as a description of current behaviour; they are not a regression claim. Apologies for the noise.
Activity
fix(plan): honor invisible indexes in optimizer (#26881)
slyunnn commentedon Aug 13, 2026
Optimizer still uses indexes marked INVISIBLE
Verification Environment
Reproduction Result
Original scenario: Still reproducible.
Evidence: after ALTER TABLE t ALTER INDEX idx_a INVISIBLE, SHOW INDEX reported Visible=NO, but EXPLAIN SELECT * FROM
t WHERE a=50 still contained Index Table Scan on t.idx_a.
Query result: the selective lookup correctly returned row (5,50,'five'), but it used the invisible index.
Reproduction frequency: reproduced in the local standalone verification.
Expected behavior: an invisible secondary index must be excluded from normal optimizer candidates; making it visible
again should restore eligibility.
Findings
The related fix is merged into the verified MatrixOne version: Yes.
Current behavior: index visibility metadata is persisted correctly, but the optimizer still selects the invisible
secondary index.
Possible cause: at least one normal index-selection path does not apply the persisted visibility eligibility check
introduced by PR fix(plan): honor invisible indexes in optimizer #26881.
Unrelated noise: invisible UNIQUE index enforcement remains correct; duplicate insertion returned ERROR 1062. This
is expected maintenance behavior and does not resolve the optimizer eligibility defect.
XuPeng-SH commentedon Aug 13, 2026
not needed
fix(plan): honor invisible indexes in optimizer (matrixorigin#26881)
fix(plan): honor invisible indexes in optimizer (matrixorigin#26881)
fix(plan): honor invisible indexes in optimizer (matrixorigin#26881)
XuPeng-SH commentedon Oct 23, 2026
Reopening: this reproduces again on current
main(3ad9adbb4c, 2026-10-22) with the exact SQL from the original report.SHOW INDEXreportsVisible = NOforidx_a:information_schema.statistics.is_visiblealso returnsNO. The planner nevertheless keeps it:Two additional data points:
create index idx_b on t(a) invisiblebehaves identically —explain select * from t where a=5000plansIndex Table Scan on t.idx_b, so it is not specific to theALTER INDEX ... INVISIBLEpath.is_visible = NOand the plan still usesidx_b, so this is not a stale session or plan cache.White-box: the only consumers of index visibility in the planner are
pkg/sql/plan/build_show_util.go:292/372/450— i.e. theSHOWrendering path. Nothing in index selection (apply_indices.go/query_builder.go) filters candidates byIndexOption_Visibility, which matches the observed behaviour: the flag is stored, reported, and ignored when choosing an access path.XuPeng-SH commentedon Oct 23, 2026
Closing again — I reopened this by mistake. Maintainers confirm that invisible indexes being metadata-only in MatrixOne is an intentional design decision, not a defect:
INVISIBLEis reported bySHOW INDEX/information_schema.statisticsand does not filter optimizer access-path candidates. The behaviour I observed is therefore expected, and the planner-side opt-in was tracked separately in #26947.My measurements above stand as a description of current behaviour; they are not a regression claim. Apologies for the noise.