Skip to content

STATISTICS shows the indexes that are not PUBLIC #60430

Closed

Description

@lawrence1223freenew

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE `TABLE_NAME` = 'part' and index_name = 'idx_mfgr';
+---------------+--------------+------------+------------+--------------+------------+--------------+-------------+-----------+-------------+----------+--------+----------+------------+---------+---------------+------------+------------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | NON_UNIQUE | INDEX_SCHEMA | INDEX_NAME | SEQ_IN_INDEX | COLUMN_NAME | COLLATION | CARDINALITY | SUB_PART | PACKED | NULLABLE | INDEX_TYPE | COMMENT | INDEX_COMMENT | IS_VISIBLE | Expression |
+---------------+--------------+------------+------------+--------------+------------+--------------+-------------+-----------+-------------+----------+--------+----------+------------+---------+---------------+------------+------------+
| def           | test         | part       | 1          | test         | idx_mfgr   |            1 | P_MFGR      | A         |           0 |     NULL | NULL   |          | BTREE      |         |               | YES        | NULL       |
+---------------+--------------+------------+------------+--------------+------------+--------------+-------------+-----------+-------------+----------+--------+----------+------------+---------+---------------+------------+------------+
1 row in set (0.00 sec)

mysql> 
mysql> admin show ddl jobs;
+--------+---------+------------+---------------------------+----------------------+-----------+----------+-----------+---------------------+---------------------+---------------------+-----------+
| JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE                  | SCHEMA_STATE         | SCHEMA_ID | TABLE_ID | ROW_COUNT | CREATE_TIME         | START_TIME          | END_TIME            | STATE     |
+--------+---------+------------+---------------------------+----------------------+-----------+----------+-----------+---------------------+---------------------+---------------------+-----------+
|    140 | test    | part       | add index /* txn-merge */ | write reorganization |         2 |       84 |   1323005 | 2025-04-08 05:31:13 | 2025-04-08 05:31:13 | NULL                | running   |
|    139 | test    | part       | drop index                | none                 |         2 |       84 |         0 | 2025-04-08 05:23:10 | 2025-04-08 05:23:10 | 2025-04-08 05:23:10 | synced    |
|    138 | test    | part       | add index /* txn-merge */ | public               |         2 |       84 |   1600000 | 2025-04-05 15:17:09 | 2025-04-05 15:17:09 | 2025-04-05 15:17:50 | synced    |
|    137 | test    | part       | drop index                | none                 |         2 |       84 |         0 | 2025-04-05 15:16:30 | 2025-04-05 15:16:30 | 2025-04-05 15:16:31 | synced    |
|    136 | test    | part       | add index /* txn-merge */ | public               |         2 |       84 |   1600000 | 2025-04-05 15:12:35 | 2025-04-05 15:12:35 | 2025-04-05 15:13:16 | synced    |
|    135 | test    | part       | drop index                | none                 |         2 |       84 |         0 | 2025-04-05 15:11:36 | 2025-04-05 15:11:36 | 2025-04-05 15:11:36 | synced    |
|    134 | test    | part       | add index                 | none                 |         2 |       84 |         0 | 2025-04-05 05:34:29 | 2025-04-05 05:35:09 | 2025-04-05 05:35:09 | cancelled |
|    133 | test    | part       | add index /* txn-merge */ | public               |         2 |       84 |   1600000 | 2025-04-05 05:34:29 | 2025-04-05 05:34:29 | 2025-04-05 05:35:09 | synced    |
|    132 | test    | part       | drop index                | public               |         2 |       84 |         0 | 2025-04-05 05:34:29 | 2025-04-05 05:34:29 | 2025-04-05 05:34:29 | cancelled |
|    131 | test    | part       | drop index                | none                 |         2 |       84 |         0 | 2025-04-05 05:34:29 | 2025-04-05 05:34:29 | 2025-04-05 05:34:29 | synced    |
|    130 | test    | t          | drop table                | none                 |         2 |      128 |         0 | 2025-04-05 05:30:30 | 2025-04-05 05:30:30 | 2025-04-05 05:30:30 | synced    |
+--------+---------+------------+---------------------------+----------------------+-----------+----------+-----------+---------------------+---------------------+---------------------+-----------+
11 rows in set (0.01 sec)

mysql> 
mysql> select version();
+---------------------+
| version()           |
+---------------------+
| 5.7.25-TiDB-v6.5.11 |
+---------------------+
1 row in set (0.00 sec)

2. What did you expect to see? (Required)

STATISTICS doesn't show the indexes that are not PUBLIC

3. What did you see instead (Required)

STATISTICS shows the indexes that are not PUBLIC

4. What is your TiDB version? (Required)

v6, v7

Activity

  1. hawkingrei commented on Apr 8, 2025

    @hawkingrei
    Contributor

    In the setDataForStatisticsInTable, we don't check the public status of the table. so we can add the check to fix this problem.

  2. self-assigned this
    on Apr 17, 2025
  3. added
    affects-6.5This bug affects the 6.5.x(LTS) versions.
    affects-7.1This bug affects the 7.1.x(LTS) versions.
    affects-7.5This bug affects the 7.5.x(LTS) versions.
    affects-8.1This bug affects the 8.1.x(LTS) versions.
    affects-8.5This bug affects the 8.5.x(LTS) versions.
    and removed on May 23, 2025
  4. added a commit that references this issue on May 23, 2025
    78e306d
  5. added 2 commits that reference this issue on Jul 8, 2025
    f57f2a2
    70dfac3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.component/ddlThis issue is related to DDL of TiDB.severity/majorsig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions