docs icon indicating copy to clipboard operation
docs copied to clipboard

tidb: add the refresh stats statement

Open 0xPoe opened this issue 2 months ago • 7 comments

First-time contributors' checklist

What is changed, added or deleted? (Required)

ref https://github.com/pingcap/tidb/issues/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.

  • [x] 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)?

  • This PR is translated from:
  • Other reference link(s): https://github.com/pingcap/tidb/issues/61273

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

0xPoe avatar Oct 07 '25 13:10 0xPoe

Summary of Changes

Hello @0xPoe, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on documenting the REFRESH STATS SQL statement for TiDB. This new documentation provides users with detailed information on how to reload optimizer statistics into memory, which is essential for maintaining optimal query performance, especially after data restorations or when manual reconciliation of in-memory statistics is required. The changes include adding the statement to relevant navigation and overview pages, alongside a dedicated, in-depth guide covering its syntax, options, and practical examples.

Highlights

  • New SQL Statement Documentation: This pull request introduces comprehensive documentation for the REFRESH STATS SQL statement, detailing its purpose, syntax, options, and usage examples within TiDB.
  • Table of Contents Integration: The REFRESH STATS statement has been added to the main Table of Contents (TOC.md) under the SQL statements section, ensuring discoverability for users.
  • SQL Statement Overview Update: An entry for REFRESH STATS has been included in the sql-statement-overview.md, providing a brief description of its function: "Reloads persisted statistics into memory for specific tables or the entire cluster."
  • Statistics Documentation Enhancement: The statistics.md file has been updated with a new section explaining how to refresh in-memory statistics using the REFRESH STATS statement, including details on targeting and initialization modes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist[bot] avatar Oct 07 '25 13:10 gemini-code-assist[bot]

Summary of Changes

Hello @0xPoe, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the TiDB documentation by adding a dedicated page for the REFRESH STATS SQL statement. This new statement allows users to explicitly reload persisted optimizer statistics into memory, which is particularly useful after external statistics restoration or when in-memory statistics need to be synchronized without a full ANALYZE operation. The changes ensure that users have clear guidance on how to manage and refresh statistics effectively within TiDB.

Highlights

  • New Documentation for REFRESH STATS: This pull request introduces comprehensive documentation for the REFRESH STATS SQL statement, detailing its purpose, syntax, and usage.
  • Integration into Documentation Structure: The new REFRESH STATS documentation has been integrated into the main Table of Contents (TOC.md) and the SQL statement overview (sql-statement-overview.md), ensuring discoverability.
  • Detailed Usage and Options: The documentation provides in-depth explanations of REFRESH STATS options, including target specification (individual tables, databases, or cluster-wide), refresh modes (FULL/LITE), and the CLUSTER keyword for broadcasting requests across TiDB nodes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist[bot] avatar Oct 07 '25 13:10 gemini-code-assist[bot]

I think this is a false positive feedback: https://github.com/pingcap/docs/actions/runs/18338863546/job/52229172406?pr=21873

0xPoe avatar Oct 08 '25 08:10 0xPoe

@time-and-fate: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

Others LGTM.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

ti-chi-bot[bot] avatar Oct 10 '25 10:10 ti-chi-bot[bot]

[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 ask for approval from qiancai. 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.

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[bot] avatar Oct 15 '25 07:10 ti-chi-bot[bot]

[LGTM Timeline notifier]

Timeline:

  • 2025-11-19 08:51:12.387233924 +0000 UTC m=+88036.036428391: :ballot_box_with_check: agreed by qiancai.

ti-chi-bot[bot] avatar Nov 19 '25 08:11 ti-chi-bot[bot]

@qiancai: Your lgtm message is repeated, so it is ignored.

In response to this:

@0xPoe The new doc is well written overall. I've added some minor comments to this PR. PTAL.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

ti-chi-bot[bot] avatar Nov 20 '25 02:11 ti-chi-bot[bot]