Conversation
…ize 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) <noreply@anthropic.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughChangesInformation Schema Documentation
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This localized documentation-only change adds guidance about the cost of querying size columns; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (2 skipped: 2 unsupported.) ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Note: if pingcap/tidb#70742 is merged in the future, we'll need to cherry-pick this doc PR to the release-8.5 branch as well. |
|
|
||
| > **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. |
There was a problem hiding this comment.
| > 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. | |
| > Querying `AVG_ROW_LENGTH`, `DATA_LENGTH`, or `INDEX_LENGTH` requires TiDB to read column-size statistics from `mysql.stats_histograms`. On clusters with a large number of tables, selecting any of these columns can consume more time and resources than selecting only `TABLE_ROWS`, which only requires row-count statistics from `mysql.stats_meta`. If you need only the estimated row count, select `TABLE_ROWS` without the size columns to avoid this overhead. |
There was a problem hiding this comment.
reason: to focus on the user-visible performance impact. The exact layout of mysql.stats_histograms is an implementation detail, and saying it holds one row for each column of every table is too absolute because the table also stores index statistics.
|
|
||
| > **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. |
There was a problem hiding this comment.
| > 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. | |
| > Querying `AVG_ROW_LENGTH`, `DATA_LENGTH`, or `INDEX_LENGTH` requires TiDB to read column-size statistics from `mysql.stats_histograms`. On clusters with a large number of tables, selecting any of these columns can consume more time and resources than selecting only `TABLE_ROWS`, which only requires row-count statistics from `mysql.stats_meta`. If you need only the estimated row count, select `TABLE_ROWS` without the size columns to avoid this overhead. |
What is changed, added or deleted? (Required)
Adds a Note to the
INFORMATION_SCHEMA.TABLESandINFORMATION_SCHEMA.PARTITIONSreference pages explaining that querying the size columns (AVG_ROW_LENGTH,DATA_LENGTH,INDEX_LENGTH) makes TiDB read per-column size statistics frommysql.stats_histograms(one row per column of every table), which costs noticeably more time and resources on clusters with many tables than querying onlyTABLE_ROWS, which reads only the smallermysql.stats_metatable.This documents the behavior introduced by pingcap/tidb#69955 (fixing pingcap/tidb#69818), where TABLE_ROWS-only queries now skip the
mysql.stats_histogramsread. The note helps users avoid the size columns when they only need the estimated row count.Which TiDB version(s) do your changes apply to? (Required)
Tips for choosing the affected version(s):
By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.
For details, see tips for choosing the affected versions.
What is the related PR or file link(s)?
AI agent involvement
Do your changes match any of the following descriptions?
Summary by CodeRabbit
TABLESandPARTITIONSreference documentation about the relative cost of retrieving table size metrics.TABLE_ROWSwhen an estimated row count is needed for better performance on clusters with many tables.