Skip to content

Document descending-order index support (pingcap/tidb#2519)#22805

Open
takaidohigasi wants to merge 2 commits intopingcap:masterfrom
takaidohigasi:feature/desc-index
Open

Document descending-order index support (pingcap/tidb#2519)#22805
takaidohigasi wants to merge 2 commits intopingcap:masterfrom
takaidohigasi:feature/desc-index

Conversation

@takaidohigasi
Copy link
Copy Markdown
Contributor

What is changed, added or deleted? (Required)

Add user-facing documentation for the descending-order index feature
introduced in pingcap/tidb#68049 (and the corresponding TiKV change in
tikv/tikv#19558).

Three files updated:

  1. system-variables.md — new tidb_enable_descending_index entry
    documenting scope, default OFF, and the TiKV-version prerequisite.
  2. sql-statements/sql-statement-create-index.md — replace the
    existing "descending indexes are not supported (similar to MySQL 5.7)"
    note with the new conditional-support description, including the
    mixed-direction composite-index example (INDEX(a ASC, b DESC)
    satisfying ORDER BY a ASC, b DESC without a Sort).
  3. mysql-compatibility.md — qualify the existing "Descending Index"
    entry so it is no longer listed as wholly unsupported.

Which TiDB version(s) do your changes apply to? (Required)

  • master (the latest development version)

The feature is gated behind tidb_enable_descending_index (default
OFF), so the visible behaviour change is opt-in. Backporting to older
release branches is not appropriate because the feature requires a
matching TiKV release that contains tikv/tikv#19558.

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

🤖 Generated with Claude Code

Add user-facing documentation for the descending-order index feature
introduced in pingcap/tidb#68049 (and the corresponding TiKV change
in tikv/tikv#19558):

  * system-variables.md: new tidb_enable_descending_index entry
    documenting scope, default OFF, and the TiKV-version prerequisite.
  * sql-statements/sql-statement-create-index.md: replace the
    "descending indexes are not supported" note with the new
    conditional-support description, including the mixed-direction
    composite-index example that motivates the feature.
  * mysql-compatibility.md: qualify the existing Descending Index entry
    so it is no longer listed as wholly unsupported.

Signed-off-by: takaidohigasi <takaidohigasi@gmail.com>
@ti-chi-bot ti-chi-bot Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. contribution This PR is from a community contributor. labels Apr 25, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 25, 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 icemap 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
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 25, 2026

Hi @takaidohigasi. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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 ti-chi-bot Bot added needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. missing-translation-status This PR does not have translation status info. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 25, 2026
Copy link
Copy Markdown
Contributor

@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 introduces documentation for descending index support, a new opt-in feature in TiDB v9.0.0 controlled by the tidb_enable_descending_index system variable. The changes include updates to the MySQL compatibility list, the CREATE INDEX statement documentation, and the addition of the new system variable's details. Review feedback focused on improving conciseness, ensuring consistent terminology, and adhering to style guide principles such as using the active voice and addressing the user in the second person.

Comment thread mysql-compatibility.md Outdated

* TiDB accepts index types such as `HASH`, `BTREE` and `RTREE` in syntax for compatibility with MySQL, but ignores them.
* Descending indexes are not supported (similar to MySQL 5.7).
* Descending-order indexes are supported when the [`tidb_enable_descending_index`](/system-variables.md#tidb_enable_descending_index-new-in-v900) system variable is set to `ON` (default `OFF`). When the variable is `OFF`, the `DESC` keyword on individual index columns is parsed but ignored, matching MySQL 5.7 behavior. When `ON`, columns marked `DESC` are stored in descending order, allowing composite indexes such as `INDEX(a ASC, b DESC)` to satisfy `ORDER BY a ASC, b DESC` with a single forward index scan and no additional `Sort` operator. This brings TiDB closer to MySQL 8.0 compatibility for descending indexes; expression and `FULLTEXT` indexes do not support `DESC`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

low

To maintain consistency with standard MySQL terminology and improve readability, consider using "Descending indexes" and splitting the long final sentence. This also clarifies the limitations for expression and FULLTEXT indexes.

Suggested change
* Descending-order indexes are supported when the [`tidb_enable_descending_index`](/system-variables.md#tidb_enable_descending_index-new-in-v900) system variable is set to `ON` (default `OFF`). When the variable is `OFF`, the `DESC` keyword on individual index columns is parsed but ignored, matching MySQL 5.7 behavior. When `ON`, columns marked `DESC` are stored in descending order, allowing composite indexes such as `INDEX(a ASC, b DESC)` to satisfy `ORDER BY a ASC, b DESC` with a single forward index scan and no additional `Sort` operator. This brings TiDB closer to MySQL 8.0 compatibility for descending indexes; expression and `FULLTEXT` indexes do not support `DESC`.
* Descending indexes are supported when the [`tidb_enable_descending_index`](/system-variables.md#tidb_enable_descending_index-new-in-v900) system variable is set to `ON` (default `OFF`). When this variable is `OFF`, the `DESC` keyword on individual index columns is parsed but ignored, matching MySQL 5.7 behavior. When `ON`, columns marked `DESC` are stored in descending order. This allows composite indexes such as `INDEX(a ASC, b DESC)` to satisfy `ORDER BY a ASC, b DESC` with a single forward index scan and no additional `Sort` operator. This brings TiDB closer to MySQL 8.0 compatibility for descending indexes. Expression and `FULLTEXT` indexes do not support `DESC`.
References
  1. Use consistent terminology. (link)
  2. Avoid unnecessary words and repetition. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Already applied verbatim — see commit d9a65a687. "Descending indexes" terminology and the split sentences (FULLTEXT exclusion on its own line) are in.

Comment thread system-variables.md Outdated
Three low-priority style fixes from the bot review on
pingcap#22805, all matching the docs styleguide:

  * mysql-compatibility.md: trim wordiness on the descending-index
    bullet ("supported as an opt-in feature starting from" -> "supported
    since"; drop the redundant default-value parenthetical).
  * sql-statement-create-index.md: use "Descending indexes" instead of
    "Descending-order indexes" for consistent terminology, and split
    the long final sentence so the FULLTEXT exclusion stands on its
    own line.
  * system-variables.md: rewrite the description in active voice and
    second person, drop "(the default)" in favour of "(default)", and
    split the toggle-semantics paragraph into two sentences.

No content changes - the technical claims and links are identical.

Signed-off-by: takaidohigasi <takaidohigasi@gmail.com>
@takaidohigasi takaidohigasi marked this pull request as ready for review April 27, 2026 00:05
@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 27, 2026
@qiancai
Copy link
Copy Markdown
Collaborator

qiancai commented Apr 27, 2026

hi @takaidohigasi, thanks for the contribution to the TiDB documentation. I noticed that the corresponding code PRs are still open, so I will hold this doc PR for now.

@qiancai
Copy link
Copy Markdown
Collaborator

qiancai commented Apr 27, 2026

/hold

@ti-chi-bot ti-chi-bot Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 27, 2026
@qiancai qiancai added the translation/doing This PR's assignee is translating this PR. label Apr 27, 2026
@ti-chi-bot ti-chi-bot Bot removed the missing-translation-status This PR does not have translation status info. label Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution This PR is from a community contributor. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. size/S Denotes a PR that changes 10-29 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.

2 participants