Skip to content

docs: document partial indexes for ADD INDEX (#21950) - #21991

Merged
ti-chi-bot[bot] merged 2 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-21950-to-release-8.5
Oct 21, 2026
Merged

ti-chi-bot[bot] merged 2 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-21950-to-release-8.5

Conversation

@ti-chi-bot

@ti-chi-bot ti-chi-bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #21950

What is changed, added, or deleted? (Required)

Document partial-index syntax, scenarios, ALTER TABLE ... ADD INDEX examples, predicate behavior, and limitations on the ADD INDEX reference page.

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 (in Chinese).

  • 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

  • 文档
    • ADD INDEX 语法新增 WHERE Expression 选项,支持创建部分索引。
    • 补充普通及唯一部分索引的创建和查询示例。
    • 新增部分索引的适用场景、支持的谓词类型及使用限制说明。
    • 说明查询条件不满足索引谓词时,系统不会选择该部分索引。

@ti-chi-bot ti-chi-bot added lgtm needs-1-more-lgtm Indicates a PR needs 1 more LGTM. requires-version-specific-changes After cherry-picked, the cherry-picked PR requires further changes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Oct 21, 2026
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pingcap/docs-cn/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 5c1ee2e6-f096-40f3-aecd-22f1e5630521
📥 Commits

Reviewing files that changed from the base of the PR and between 38d7a95 and 7e40855.

📒 Files selected for processing: 1
  • sql-statements/sql-statement-add-index.md

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

📝 Walkthrough

文档为 ADD INDEX 新增 WHERE Expression 语法,介绍部分索引的定义、创建和查询示例,并列出谓词支持范围及限制。

Changes: 部分索引文档

层 / 文件 摘要
语法与创建示例
sql-statements/sql-statement-add-index.md
新增 WHERE Expression 语法,介绍部分索引和适用场景,并提供普通及唯一部分索引的创建示例。
使用示例与限制
sql-statements/sql-statement-add-index.md
新增查询及查询计划示例,说明查询谓词不满足索引条件时,即使使用 hint 也不会选择该部分索引。列出支持的谓词类型、列与常量的类型要求、同表列限制,以及不支持表达式索引的限制。

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~7 minutes

Change: Other

Suggested reviewers: qiancai

Merge Risk: 🟡 Moderate · up to 7e408

The documentation may lead users to trust unsafe partial-index hints that silently omit rows; correct the warning and version scope before merging.

Architecture risk: 🔵 Low · up to 7e408

The change affects 1 system.

Changed systems: sql-statements

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — sql-statements (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in sql-statements/sql-statement-add-index.md: IndexOption 新增 WHERE Expression,允许 ADD INDEX 语句定义部分索引谓词。
  • observed — Modified behavior in sql-statements/sql-statement-add-index.md: 新增部分索引定义及 v8.5.7 引入信息,说明索引仅包含满足谓词条件的行对应的索引条目。
  • observed — Modified behavior in sql-statements/sql-statement-add-index.md: 新增部分索引的适用场景,涵盖选择性过滤、条件唯一性和减少 DML 索引维护开销。
  • observed — Modified behavior in sql-statements/sql-statement-add-index.md: 新增通过 WHERE 子句创建普通和唯一部分索引的 SQL 示例。
Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed 标题准确概括了主要变更:为 ADD INDEX 语法补充部分索引文档。标题简洁、明确,并与变更内容一致。
Description check Passed 描述包含必需的变更说明、适用版本、相关链接、AI 参与情况和变更类型检查项。内容与文档变更及自动 cherry-pick 目的相符。
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. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: pingcap/docs-cn/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 75c4fc9e-b1ce-4ef3-8225-2668dcdfd6f6
📥 Commits

Reviewing files that changed from the base of the PR and between c44ea97 and 38d7a95.

📒 Files selected for processing: 1
  • sql-statements/sql-statement-add-index.md

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

Comment thread sql-statements/sql-statement-add-index.md
Comment thread sql-statements/sql-statement-add-index.md Outdated
@qiancai

qiancai commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

/approve

@ti-chi-bot

ti-chi-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiancai

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

The pull request process is described 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 the approved label Oct 21, 2026
@ti-chi-bot
ti-chi-bot Bot merged commit 0d5a286 into pingcap:release-8.5 Oct 21, 2026
11 checks passed
@ti-chi-bot
ti-chi-bot Bot deleted the cherry-pick-21950-to-release-8.5 branch October 21, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm needs-1-more-lgtm Indicates a PR needs 1 more LGTM. requires-version-specific-changes After cherry-picked, the cherry-picked PR requires further changes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants