Skip to content

Conversation

@shaoxiqian
Copy link
Contributor

@shaoxiqian shaoxiqian commented Sep 28, 2025

  • Query optimization with partition pruning
  • Performance comparison: Non-Partitioned vs Local Index vs Global Index
  • Data cleanup efficiency: TTL vs DROP PARTITION
  • Partition drop performance: Local Index vs Global Index
  • Strategies to mitigate write hotspot issues with hash/key partitioning
  • Partition management challenges and best practices
    • Avoiding read/write hotspots on new partitions
    • Using PRE_SPLIT_REGIONS, SHARD_ROW_ID_BITS, and region splitting
  • Converting between partitioned and non-partitioned tables
    • Batch DML, Pipeline DML, IMPORT INTO, and Online DDL efficiency comparison

First-time contributors' checklist

What is changed, added or deleted? (Required)

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)?

  • This PR is translated from:
  • Other reference 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

- Query optimization with partition pruning
- Performance comparison: Non-Partitioned vs Local Index vs Global Index
- Data cleanup efficiency: TTL vs DROP PARTITION
- Partition drop performance: Local Index vs Global Index
- Strategies to mitigate write hotspot issues with hash/key partitioning
- Partition management challenges and best practices
  - Avoiding read/write hotspots on new partitions
  - Using PRE_SPLIT_REGIONS, SHARD_ROW_ID_BITS, and region splitting
- Converting between partitioned and non-partitioned tables
  - Batch DML, Pipeline DML, IMPORT INTO, and Online DDL efficiency comparison
@ti-chi-bot ti-chi-bot bot added the missing-translation-status This PR does not have translation status info. label Sep 28, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @shaoxiqian, 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 introduces a comprehensive guide on mastering partitioned tables in TiDB. It covers critical aspects such as optimizing query performance through partition pruning and global indexes, efficiently managing bulk data deletion with DROP PARTITION versus TTL, mitigating write hotspots using hash/key partitioning, and best practices for managing new range partitions. The guide also provides a detailed comparison of methods for converting tables between partitioned and non-partitioned states, offering practical insights and recommendations for effective TiDB environment management.

Highlights

  • Query Optimization: Details how partition pruning enhances query efficiency and compares performance across non-partitioned, local index, and global index configurations, providing insights into when to use each.
  • Bulk Data Deletion: Explores the efficiency of data cleanup using TTL versus direct partition drops, highlighting the significant performance advantages of DROP PARTITION and its implications for local vs. global indexes.
  • Write Hotspot Mitigation: Discusses strategies, particularly hash/key partitioning, to alleviate write hotspot issues caused by monotonically increasing primary keys, improving load distribution and throughput.
  • Partition Management: Addresses common challenges like read and write hotspots in new range partitions and provides solutions using SHARD_ROW_ID_BITS, PRE_SPLIT_REGIONS, and region splitting for both NONCLUSTERED and CLUSTERED tables.
  • Table Conversion Methods: Compares the efficiency of various methods (Batch DML, Pipeline DML, IMPORT INTO, Online DDL) for converting between partitioned and non-partitioned tables, offering recommendations for optimal performance.
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 28, 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 a comprehensive guide on using partitioned tables in TiDB. The document covers various aspects from query optimization and data cleanup to mitigating hotspots and managing partitions. My review focuses on improving clarity, consistency, and adherence to the documentation style guide. I've suggested changes to use sentence case for headings, ensure consistent terminology for 'global index' and 'local index', and improve phrasing for better readability. I also found some minor typos and inconsistencies in code examples that could confuse readers.

@shaoxiqian shaoxiqian changed the title adds a new guide on mastering partitioned tables in TiDB add a new guide on mastering partitioned tables in TiDB Sep 28, 2025
shaoxiqian and others added 6 commits September 28, 2025 13:13
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…p/docs into Mastering-TiDB-Partitioned-Tables
@shaoxiqian
Copy link
Contributor Author

/retest

shaoxiqian and others added 2 commits September 29, 2025 10:34
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 29, 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 ask for approval from hfxsd. 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

1 similar comment
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 29, 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 ask for approval from hfxsd. 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

shaoxiqian and others added 2 commits September 29, 2025 10:35
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
shaoxiqian and others added 2 commits September 29, 2025 20:13
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@shaoxiqian
Copy link
Contributor Author

/test pull-verify

@shaoxiqian
Copy link
Contributor Author

/test pull-verify

Copy link
Contributor

@dveeden dveeden left a comment

Choose a reason for hiding this comment

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

Please add to the TOC as per my previous comment

shaoxiqian and others added 4 commits October 14, 2025 20:10
Renamed and relocated 'tidb-partitioned-tables-guide.md' to 'best-practices/tidb-partitioned-tables-guide.md'. Updated TOC.md to reference the new location and added front matter and editorial improvements to the guide for clarity and consistency.
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Oct 15, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 15, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-10-03 08:14:25.172266392 +0000 UTC m=+418045.428997792: ✖️🔁 reset by dveeden.
  • 2025-10-14 11:57:15.919784395 +0000 UTC m=+181741.997036955: ✖️🔁 reset by dveeden.
  • 2025-10-15 07:23:04.318583067 +0000 UTC m=+251690.395835627: ☑️ agreed by dveeden.

hfxsd and others added 9 commits October 15, 2025 17:18
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 27, 2025

@shaoxiqian: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-verify 0dd7df8 link true /test pull-verify

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

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

Labels

area/best-practices Adds or updates TiDB best practices. needs-1-more-lgtm Indicates a PR needs 1 more LGTM. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. translation/doing This PR's assignee is translating this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants