From 51e5a57da4963477cc112980effab8751f864ecf Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Mon, 20 Jul 2026 22:35:19 +0200 Subject: [PATCH] information-schema: note the extra cost of querying TABLE/PARTITION size columns Add a note to the TABLES and PARTITIONS pages explaining that AVG_ROW_LENGTH, DATA_LENGTH, and INDEX_LENGTH read per-column size statistics from mysql.stats_histograms and cost more than querying only TABLE_ROWS, which reads only mysql.stats_meta. Documents the behavior from pingcap/tidb#69818. Co-Authored-By: Claude Opus 4.8 (1M context) --- information-schema/information-schema-partitions.md | 4 ++++ information-schema/information-schema-tables.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/information-schema/information-schema-partitions.md b/information-schema/information-schema-partitions.md index 61510949922ab..bbb98ad0fe567 100644 --- a/information-schema/information-schema-partitions.md +++ b/information-schema/information-schema-partitions.md @@ -7,6 +7,10 @@ summary: Learn the `PARTITIONS` INFORMATION_SCHEMA table. The `PARTITIONS` table provides information about [partitioned tables](/partitioned-table.md). +> **Note:** +> +> Computing `AVG_ROW_LENGTH`, `DATA_LENGTH`, or `INDEX_LENGTH` requires TiDB to read per-column size statistics from the `mysql.stats_histograms` system table, which holds one row for each column of every table. On clusters with a large number of tables, selecting any of these columns can consume noticeably more time and resources than selecting only `TABLE_ROWS`, which reads only the smaller `mysql.stats_meta` system table. If you need only the estimated row count, select `TABLE_ROWS` without the size columns to avoid this overhead. + ```sql USE INFORMATION_SCHEMA; DESC partitions; diff --git a/information-schema/information-schema-tables.md b/information-schema/information-schema-tables.md index 77eb125c82bde..0bf33f43caf4f 100644 --- a/information-schema/information-schema-tables.md +++ b/information-schema/information-schema-tables.md @@ -123,6 +123,10 @@ The description of columns in the `TABLES` table is as follows: * `CREATE_OPTIONS`: Creates options. * `TABLE_COMMENT`: The comments and notes of the table. +> **Note:** +> +> Computing `AVG_ROW_LENGTH`, `DATA_LENGTH`, or `INDEX_LENGTH` requires TiDB to read per-column size statistics from the `mysql.stats_histograms` system table, which holds one row for each column of every table. On clusters with a large number of tables, selecting any of these columns can consume noticeably more time and resources than selecting only `TABLE_ROWS`, which reads only the smaller `mysql.stats_meta` system table. If you need only the estimated row count, select `TABLE_ROWS` without the size columns to avoid this overhead. + Most of the information in the table is the same as MySQL. The following columns are newly defined by TiDB: * `TIDB_TABLE_ID`: to indicate the internal ID of a table. This ID is unique in a TiDB cluster.