Skip to content

tidb: add the refresh stats statement#21598

Open
qiancai wants to merge 4 commits into
pingcap:masterfrom
qiancai:poe-patch-refresh-stats-21873
Open

tidb: add the refresh stats statement#21598
qiancai wants to merge 4 commits into
pingcap:masterfrom
qiancai:poe-patch-refresh-stats-21873

Conversation

@qiancai
Copy link
Copy Markdown
Collaborator

@qiancai qiancai commented Apr 29, 2026

First-time contributors' checklist

What is changed, added or deleted? (Required)

ref pingcap/tidb#61273

Added the documentation for the refresh stats statement.

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)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)

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

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

@qiancai qiancai added translation/from-docs This PR is translated from a PR in pingcap/docs. v9.0-beta.3 This PR/issue applies to TiDB v9.0-beta.3. labels Apr 29, 2026
@ti-chi-bot ti-chi-bot Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 29, 2026
Synced from: pingcap/docs#21873
Target PR: pingcap#21598
AI Provider: azure

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

Auto-sync completed successfully

Source PR: pingcap/docs#21873
Target PR: #21598

Chinese documentation has been updated based on English documentation changes.

@github-actions github-actions Bot force-pushed the poe-patch-refresh-stats-21873 branch from 9b7b077 to 2182627 Compare April 29, 2026 09:08
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 29, 2026

[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 lance6716 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 size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 29, 2026
@ti-chi-bot ti-chi-bot Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 6, 2026
Comment thread sql-statements/sql-statement-refresh-stats.md Outdated
@qiancai qiancai self-assigned this May 8, 2026
Comment thread TOC.md
- [`PREPARE`](/sql-statements/sql-statement-prepare.md)
- [`QUERY WATCH`](/sql-statements/sql-statement-query-watch.md)
- [`RECOVER TABLE`](/sql-statements/sql-statement-recover-table.md)
- [`刷新统计信息`](/sql-statements/sql-statement-refresh-stats.md)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [`刷新统计信息`](/sql-statements/sql-statement-refresh-stats.md)
- [`REFRESH STATS`](/sql-statements/sql-statement-refresh-stats.md)


- **Targets(`RefreshTargetList`)**:
- `table_name`:刷新当前数据库中的指定表。
- `db_name.table_name`:刷新指定数据库中的指定表。。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `db_name.table_name`:刷新指定数据库中的指定表。
- `db_name.table_name`:刷新指定数据库中的指定表。


## 选项

- **Targets(`RefreshTargetList`)**:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Targets`RefreshTargetList`**
- **刷新目标`RefreshTargetList`**

- `db_name.*`:刷新指定数据库中的所有表。
- `*.*`:刷新集群中的所有表。
- **`FULL`**:将完整的统计信息(例如直方图、TopN 和 CMSketch)加载到内存中,等同于针对本次操作将 [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710) 设置为 `false`。当你需要立即获得完整统计信息时,可使用该选项。
- **`LITE`**:执行轻量级初始化,等同于设置 `lite-init-stats = true`。该模式会跳过直方图和其他较重的数据结构的加载,直到真正需要时才进行加载。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **`LITE`**:执行轻量级初始化,等同于设置 `lite-init-stats = true`该模式会跳过直方图和其他较重的数据结构的加载,直到真正需要时才进行加载
- **`LITE`**:执行轻量级初始化,等同于设置 `lite-init-stats = true`该模式会跳过直方图等较重数据结构的加载,直到真正需要时才加载

- **`FULL`**:将完整的统计信息(例如直方图、TopN 和 CMSketch)加载到内存中,等同于针对本次操作将 [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710) 设置为 `false`。当你需要立即获得完整统计信息时,可使用该选项。
- **`LITE`**:执行轻量级初始化,等同于设置 `lite-init-stats = true`。该模式会跳过直方图和其他较重的数据结构的加载,直到真正需要时才进行加载。
- **`CLUSTER`**:将刷新请求发送到所有 TiDB 服务器。如果不指定该选项,则只有接收到该语句的 TiDB 节点会重新加载其内存中的统计信息。
- **默认模式**:如果既未指定 `FULL`,也未指定 `LITE`,TiDB 会使用 [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710) 的当前值。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **默认模式**:如果既未指定 `FULL`,也未指定 `LITE`,TiDB 会使用 [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-new-in-v710) 的当前值。
- **默认模式**:如果既未指定 `FULL`,也未指定 `LITE`,TiDB 会使用 [`lite-init-stats`](/tidb-configuration-file.md#lite-init-stats-从-v710-版本开始引入) 的当前值。

REFRESH STATS orders;
```

- 以轻量级初始化刷新 `sales` 中的所有表:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 以轻量级初始化刷新 `sales` 中的所有表:
- 以轻量级初始化方式刷新 `sales` 中的所有表:


## MySQL 兼容性

`REFRESH STATS` 是 TiDB 特有的扩展,不属于 MySQL。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`REFRESH STATS` TiDB 特有的扩展,不属于 MySQL。
`REFRESH STATS` 语句是 TiDB MySQL 语法的扩展

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label May 20, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented May 20, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-05-20 09:09:24.569276978 +0000 UTC m=+341694.073407653: ☑️ agreed by Oreoxmt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-1-more-lgtm Indicates a PR needs 1 more LGTM. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. translation/from-docs This PR is translated from a PR in pingcap/docs. 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