Skip to content

Conversation

0xPoe
Copy link
Member

@0xPoe 0xPoe commented Oct 7, 2025

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

Copy link

ti-chi-bot bot commented Oct 7, 2025

[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 tangenta 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.

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 the missing-translation-status This PR does not have translation status info. label Oct 7, 2025
Copy link

Summary of Changes

Hello @0xPoe, I'm Gemini Code Assist1! 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 👍 and 👎 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.

Footnotes

  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.

@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 7, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds documentation for the new REFRESH STATS statement. The changes include adding the new statement to the table of contents and SQL overview, creating a new page for REFRESH STATS, and updating the statistics documentation. The new documentation is well-written and comprehensive. I've provided a couple of minor suggestions to improve wording and consistency with the style guide. Overall, great work!

Copy link

Summary of Changes

Hello @0xPoe, I'm Gemini Code Assist1! 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 👍 and 👎 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.

Footnotes

  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.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds documentation for the new REFRESH STATS SQL statement. The changes are well-structured and introduce the new feature clearly by adding it to the table of contents, the SQL statements overview, and its own dedicated page. A brief mention is also added to the main statistics documentation. The new content is comprehensive and follows the documentation style guide. I have a few minor suggestions to enhance consistency and readability, which are detailed in the comments.

@0xPoe 0xPoe force-pushed the poe-patch-refresh-stats branch 2 times, most recently from 92509e0 to 8252698 Compare October 7, 2025 13:25
@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 8, 2025
@0xPoe 0xPoe requested a review from qiancai October 8, 2025 08:40
@0xPoe
Copy link
Member Author

0xPoe commented Oct 8, 2025

fix: update warnings

Apply suggestion from @gemini-code-assist[bot]

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

Apply suggestion from @gemini-code-assist[bot]

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

fix: remove unnessary part

fix: update privileges

fix: correct the link

fix: update link style

fix: make lint happy

fix: make lint happy

fix : make lint happy
@0xPoe 0xPoe force-pushed the poe-patch-refresh-stats branch from 97ebd59 to 063ebec Compare October 8, 2025 08:44
@qiancai qiancai self-assigned this Oct 9, 2025
@qiancai qiancai added v9.0-beta.3 This PR/issue applies to TiDB v9.0-beta.3. translation/doing This PR's assignee is translating this PR. and removed missing-translation-status This PR does not have translation status info. labels Oct 9, 2025
Copy link
Member

@time-and-fate time-and-fate left a comment

Choose a reason for hiding this comment

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

Others LGTM.


> **Warning:**
>
> This statement exists primarily for BR workflows that must reload statistics after a physical restore. Outside of BR, only run it when you explicitly debug in-memory statistics, and do not execute it on production clusters during ordinary operations.
Copy link
Member

Choose a reason for hiding this comment

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

If I understand it correctly, the user doesn't need to run this statement even in the BR workflow.
I think the current wording may lead readers to mistakenly think that they need to run this statement if they are using BR. I think it's better to explicitly say that it's used by BR internally.

Copy link

ti-chi-bot bot commented Oct 10, 2025

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XXL Denotes a PR that changes 1000+ 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.

3 participants