Skip to content

query results of information_schema.tables not accurate #55803

@fubinzh

Description

@fubinzh

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. br restore a backup with 10 tables, each table 500k rows.
  2. all table is analyzed (auto/manual)
  3. Run below query to get information of the tables.
    select table_name, avg_row_length, max_data_length, data_length, table_rows from information_schema.tables where table_schema = 'db500k';

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

The table information should be accurate.

3. What did you see instead (Required)

The query results not accurate, there is no max_data_length . and some tables has no results.
Also, run the query multple times, result might be different.

mysql> SHOW STATS_META where db_name='db500k';
+---------+-------------+----------------+---------------------+--------------+-----------+---------------------+
| Db_name | Table_name  | Partition_name | Update_time         | Modify_count | Row_count | Last_analyze_time   |
+---------+-------------+----------------+---------------------+--------------+-----------+---------------------+
| db500k | index_Data4 |                | 2024-09-02 13:28:24 |            0 |    500000 | 2024-09-02 13:28:24 |
| db500k | index_Data3 |                | 2024-09-02 13:28:23 |            0 |    500000 | 2024-09-02 13:28:23 |
| db500k | index_Data1 |                | 2024-09-02 13:28:24 |            0 |    500000 | 2024-09-02 13:28:24 |
| db500k | index_Data2 |                | 2024-09-02 13:28:23 |            0 |    500000 | 2024-09-02 13:28:23 |
| db500k | index_Data5 |                | 2024-09-02 13:28:24 |            0 |    500000 | 2024-09-02 13:28:24 |
| db500k | Data4       |                | 2024-09-02 13:30:39 |            0 |    500000 | 2024-09-02 13:30:39 |
| db500k | Data5       |                | 2024-09-02 13:30:38 |            0 |    500000 | 2024-09-02 13:30:38 |
| db500k | Data2       |                | 2024-09-02 13:30:41 |            0 |    500000 | 2024-09-02 13:30:41 |
| db500k | Data3       |                | 2024-09-02 13:30:40 |            0 |    500000 | 2024-09-02 13:30:40 |
| db500k | Data1       |                | 2024-09-02 13:30:39 |            0 |    500000 | 2024-09-02 13:30:38 |
+---------+-------------+----------------+---------------------+--------------+-----------+---------------------+
10 rows in set (0.05 sec)
mysql> select table_name, avg_row_length, max_data_length, data_length, table_rows from information_schema.tables where table_schema = 'db500k';
+-------------+----------------+-----------------+-------------+------------+
| table_name  | avg_row_length | max_data_length | data_length | table_rows |
+-------------+----------------+-----------------+-------------+------------+
| index_Data4 |            135 |               0 |    67991573 |     500000 |
| index_Data3 |              0 |               0 |           0 |          0 |
| index_Data1 |              0 |               0 |           0 |          0 |
| index_Data2 |              0 |               0 |           0 |          0 |
| index_Data5 |              0 |               0 |           0 |          0 |
| Data4       |              0 |               0 |           0 |          0 |
| Data5       |              0 |               0 |           0 |          0 |
| Data2       |              0 |               0 |           0 |          0 |
| Data3       |              0 |               0 |           0 |          0 |
| Data1       |              0 |               0 |           0 |          0 |
+-------------+----------------+-----------------+-------------+------------+
10 rows in set (0.05 sec)

4. What is your TiDB version? (Required)

Master
Edition: Community
Git Commit Hash: 94666a2

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions