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]: information_schema.STATISTICS reports zero cardinality after ANALYZE on populated indexes #31164
information_schema.STATISTICS.CARDINALITY reports 0 for populated primary and secondary indexes even after a successful ANALYZE TABLE. This falsely presents each populated index as having no distinct keys.
Environment
Branch: official main
Commit: 5fe08a3307e246e1ab9951ab690b50557af0f509
Deployment: fresh isolated LOG/TN/CN cluster, SQL port 36601, 2026-10-26
Reference: isolated MySQL 8.3.0, local socket only
Steps to reproduce
CREATEDATABASEqa_indexcard_repro;
CREATETABLEqa_indexcard_repro.t (
id INTPRIMARY KEY, v INT, KEY ix_v(v)
);
INSERT INTOqa_indexcard_repro.tVALUES
(1,10),(2,20),(3,30),(4,40),(5,50),(6,60),(7,70),(8,80);
ANALYZE TABLE qa_indexcard_repro.t;
SELECT index_name,cardinality FROMinformation_schema.statisticsWHERE table_schema='qa_indexcard_repro'AND table_name='t'ORDER BY index_name;
SELECTCOUNT(*),COUNT(DISTINCT v) FROMqa_indexcard_repro.t;
Actual behavior
MatrixOne ANALYZE TABLE reports population_rows=8, population_exact=1, sample_rows=8, status OK, while both PRIMARY and ix_v cardinality remain 0. This occurred in three independent fresh databases (3/3).
Expected behavior
The metadata should report a nonzero estimate after analyzing indexes with eight distinct keys. MySQL 8.3.0 reports 8 for both indexes in each of the same three fixtures. If the index cardinality is unavailable, it should not be falsely represented as known zero.
pkg/util/sysview/predefined.goInformationSchemaStatisticsDDL emits the literal 0 AS CARDINALITY for every index. The index-statistics view does not use the populated table/index statistics even after ANALYZE. This is distinct from #30910, which tracks information_schema.TABLES row/size fields, not index cardinality.
Regression coverage
Assert primary and secondary index cardinality metadata for empty, low-NDV and high-NDV tables before/after ANALYZE, with query results and statistics status as controls.
Tracking consolidated into #30910. The canonical issue retains this report’s full reproduction/discussion and independent acceptance requirements. This is administrative consolidation, not a claim that the defect is fixed. Original evidence remains preserved here.
Activity
XuPeng-SH commentedon Oct 26, 2026
Tracking consolidated into #30910. The canonical issue retains this report’s full reproduction/discussion and independent acceptance requirements. This is administrative consolidation, not a claim that the defect is fixed. Original evidence remains preserved here.
fix(sysview): publish real table and index statistics in information_…