Skip to content

information-schema: note the extra cost of querying TABLE/PARTITION size columns - #23685

Open
mjonss wants to merge 1 commit into
pingcap:masterfrom
mjonss:table-rows-only-stats-cost-69818
Open

information-schema: note the extra cost of querying TABLE/PARTITION size columns#23685
mjonss wants to merge 1 commit into
pingcap:masterfrom
mjonss:table-rows-only-stats-cost-69818

Conversation

@mjonss

@mjonss mjonss commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What is changed, added or deleted? (Required)

Adds a Note to the INFORMATION_SCHEMA.TABLES and INFORMATION_SCHEMA.PARTITIONS reference pages explaining that querying the size columns (AVG_ROW_LENGTH, DATA_LENGTH, INDEX_LENGTH) makes TiDB read per-column size statistics from mysql.stats_histograms (one row per column of every table), which costs noticeably more time and resources on clusters with many tables than querying only TABLE_ROWS, which reads only the smaller mysql.stats_meta table.

This documents the behavior introduced by pingcap/tidb#69955 (fixing pingcap/tidb#69818), where TABLE_ROWS-only queries now skip the mysql.stats_histograms read. 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.

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)

What is the related PR or file link(s)?

AI agent involvement

  • The changes in this PR were primarily made by an AI agent on behalf of the PR author.

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Summary by CodeRabbit

  • Documentation
    • Added guidance to TABLES and PARTITIONS reference documentation about the relative cost of retrieving table size metrics.
    • Recommended selecting only TABLE_ROWS when an estimated row count is needed for better performance on clusters with many tables.

…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>
@ti-chi-bot

ti-chi-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign csuzhangxc for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added missing-translation-status This PR does not have translation status info. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 1, 2026
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 9412f484-3d3a-44dd-b97b-1de98e04d724

📥 Commits

Reviewing files that changed from the base of the PR and between a49788b and 51e5a57.

📒 Files selected for processing (2)
  • information-schema/information-schema-partitions.md
  • information-schema/information-schema-tables.md

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Information Schema Documentation

Layer / File(s) Summary
Statistics query guidance
information-schema/information-schema-partitions.md, information-schema/information-schema-tables.md
Adds notes explaining that size statistics read mysql.stats_histograms, while TABLE_ROWS reads mysql.stats_meta. Recommends selecting only TABLE_ROWS when an estimated row count is needed.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 51e5a

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)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main documentation change: noting the additional cost of querying table and partition size columns.
Description check ✅ Passed The description explains the changes, affected TiDB version, related issue and PR, AI involvement, and applicable change classifications. All required sections are present and sufficiently complete.
Docstring Coverage ✅ Passed 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…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

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)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qiancai qiancai self-assigned this Sep 3, 2026
@qiancai

qiancai commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

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.

@qiancai qiancai added the translation/doing This PR's assignee is translating this PR. label Sep 3, 2026
@ti-chi-bot ti-chi-bot Bot removed the missing-translation-status This PR does not have translation status info. label Sep 3, 2026
@qiancai qiancai added missing-translation-status This PR does not have translation status info. v9.0-beta.3 This PR/issue applies to TiDB v9.0-beta.3. labels Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-translation-status This PR does not have translation status info. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. translation/doing This PR's assignee is translating this PR. v9.0-beta.3 This PR/issue applies to TiDB v9.0-beta.3.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants