Metadata Table Statistics

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 元数据表统计信息

| username: 摊煎饼果子的蒙其

How much difference can there be between querying the database size using metadata tables and the actual data volume?

SELECT TABLE_SCHEMA, TABLE_ROWS, CONCAT(ROUND(SUM(DATA_LENGTH + INDEX_LENGTH + DATA_FREE) / 1024 / 1024 / 1024), 'G') 
FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA NOT IN ('INFORMATION_SCHEMA', 'METRICS_SCHEMA', 'PERFORMANCE_SCHEMA', 'mysql') 
GROUP BY TABLE_SCHEMA, TABLE_ROWS 
ORDER BY 3 DESC;
| username: tidb菜鸟一只 | Original post link

TiDB is not very accurate with this; it relies heavily on statistical information.

| username: 天蓝色的小九 | Original post link

The difference depends on the statistics. You can check the monitoring.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.