Skip to content

docs: add a guide for configuring slow query trigger rules (#23767) - #23873

Open
ti-chi-bot wants to merge 1 commit into
pingcap:masterfrom
ti-chi-bot:cherry-pick-23767-to-master
Open

ti-chi-bot wants to merge 1 commit into
pingcap:masterfrom
ti-chi-bot:cherry-pick-23767-to-master

Conversation

@ti-chi-bot

@ti-chi-bot ti-chi-bot commented Sep 15, 2026

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #23767

What is changed, added or deleted? (Required)

Add a standalone guide for configuring slow query trigger rules so that users can find the supported fields, syntax constraints, matching behavior, and examples in one place.

The guide distinguishes the supported rule scopes and behavior for TiDB Self-Managed, TiDB Cloud Dedicated, and TiDB Cloud Essential/Premium. It also updates the related system variable documentation, TiDB Cloud performance guide, navigation entries, and cross-references.

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)
  • v8.5 (TiDB 8.5 versions)
  • v8.4 (TiDB 8.4 versions)
  • v8.3 (TiDB 8.3 versions)
  • v8.2 (TiDB 8.2 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)?

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

  • New Features

    • Added documentation for configuring slow-query trigger rules using tidb_slow_log_rules.
    • Documented supported conditions, matching behavior, scope differences, examples, and performance recommendations.
    • Added references to the new guide throughout the troubleshooting, CLI, and performance documentation.
  • Documentation

    • Updated system-variable documentation with TiDB Cloud availability, version details, scope, and usage guidance.
    • Refreshed slow-query logging links and clarified configuration guidance for TiDB Cloud plans.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm requires-version-specific-changes After cherry-picked, the cherry-picked PR requires further changes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-master This PR is cherry-picked to master from a source PR. labels Sep 15, 2026
@ti-chi-bot

Copy link
Copy Markdown
Member Author

@qiancai This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot

ti-chi-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

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 ti-community-infra/tichi repository.

@ti-chi-bot

ti-chi-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

[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 ti-chi-bot Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 15, 2026
@ti-chi-bot

ti-chi-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

@ti-chi-bot: 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 84244bc link true /test pull-verify

Full PR test history. Your PR dashboard.

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

@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The pull request adds a slow query trigger rule guide, updates related system-variable and Cloud documentation, adds TOC links, and introduces unresolved merge-conflict markers in several documentation files.

Changes

Slow query trigger rules

Layer / File(s) Summary
Trigger rule guide
config-slow-query-trigger-rules.md
Adds syntax, scope, supported fields, matching order, examples, overwrite behavior, fallback behavior, and performance guidance for tidb_slow_log_rules.
System-variable and navigation integration
system-variables.md, releases/release-8.5.6.md, TOC.md, TOC-tidb-cloud-essential.md, tidb-cloud/tune-performance.md
Updates platform support and version information, links to the new guide, and adds navigation entries for the guide.
Conflict-marker changes in related documentation
TOC-tidb-cloud-premium.md, identify-slow-queries.md
Adds unresolved merge-conflict markers, duplicate entries, and conflicting links or version anchors.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Suggested reviewers: qiancai

Merge Risk: 🟡 Moderate · up to 84244

The documentation can publish conflict text, contradictory version details, and unsupported Starter instructions, so it should be corrected before merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: adding a guide for configuring slow query trigger rules.
Description check ✅ Passed The description explains the changes, affected versions, AI involvement, and required version-specific modifications. It is mostly complete, although the related-reference fields are empty and the kno…
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.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 6d79697f-555d-46f9-9fcb-97708ef8c88b

📥 Commits

Reviewing files that changed from the base of the PR and between eed05b5 and 84244bc.

📒 Files selected for processing (8)
  • TOC-tidb-cloud-essential.md
  • TOC-tidb-cloud-premium.md
  • TOC.md
  • config-slow-query-trigger-rules.md
  • identify-slow-queries.md
  • releases/release-8.5.6.md
  • system-variables.md
  • tidb-cloud/tune-performance.md

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.

- If the current session has any applicable `tidb_slow_log_rules` rules, slow query logging is determined by the rule matching results, and [`tidb_slow_log_threshold`](/system-variables.md#tidb_slow_log_threshold) is ignored.

</CustomContent>
<CustomContent platform="tidb-cloud">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Call out the Starter limitation in the TiDB Cloud introduction.

The TiDB Cloud block is shown on the TiDB Cloud documentation site, and tidb_slow_log_rules is not supported on TiDB Cloud Starter. Its current text tells all Cloud users to modify the variable. Add the limitation before that instruction:

Suggested change
<CustomContent platform="tidb-cloud">
<CustomContent platform="tidb-cloud">
TiDB Cloud Starter does not support [`tidb_slow_log_rules`](/system-variables.md#tidb_slow_log_rules). For TiDB Cloud Essential, Premium, and Dedicated, you can modify this system variable in the [TiDB Cloud console](https://tidbcloud.com/).
In the [TiDB Cloud console](https://tidbcloud.com/), you can view slow queries on the [**Slow Query**](/tidb-cloud/tune-performance.md#slow-query) tab of the [**Diagnosis**](/tidb-cloud/tune-performance.md#view-the-diagnosis-page) page.
By default, SQL queries that take more than 300 milliseconds are considered as slow queries. To configure the trigger rules for slow queries, you can modify the [`tidb_slow_log_rules`](/system-variables.md#tidb_slow_log_rules) system variable.
[`tidb_slow_log_rules`](/system-variables.md#tidb_slow_log_rules) supports multi-dimensional metric combinations. It is suitable for "targeted sampling" and "problem reproduction" of slow queries, enabling you to filter target statements based on specific metric combinations.
</CustomContent>

Do not add a plan attribute to the system-variables.md block. It already states that the variable is unsupported on Starter, matching the repository pattern for other variables with plan limitations. The guide's shared syntax and examples are also intentionally reused across supported platforms, while the later plan-specific blocks distinguish the available scopes.

Comment thread identify-slow-queries.md
SELECT /*+ WRITE_SLOW_LOG */ count(*) FROM t t1, t t2 WHERE t1.a = t2.b;
```

<<<<<<< HEAD

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- identify-slow-queries.md affected ranges ---'
sed -n '175,205p;305,345p' identify-slow-queries.md
printf '%s\n' '--- TOC-tidb-cloud-premium.md affected range ---'
sed -n '550,575p' TOC-tidb-cloud-premium.md
printf '%s\n' '--- canonical variable references ---'
rg -n -C 3 'tidb_slow_log_max_per_sec|tidb_slow_log_rules' system-variables.md identify-slow-queries.md config-slow-query-trigger-rules.md 2>/dev/null || true
printf '%s\n' '--- conflict markers in the two files ---'
rg -n '^(<<<<<<<|=======|>>>>>>>)' identify-slow-queries.md TOC-tidb-cloud-premium.md || true

Repository: pingcap/docs

Length of output: 34484


🤖 get_repo_knowledge executed:

get_repo_knowledge pingcap/docs /tmp/coderabbit-repo-knowledge/pingcap-docs-9c73f70c/learnings /tmp/coderabbit-repo-knowledge/pingcap-docs-9c73f70c/conventions

Length of output: 4069


Resolve all Git merge conflicts before publishing the documentation.

Both files contain unresolved conflict markers. These markers can publish as literal text and leave duplicate sections, inconsistent links, and conflicting version claims.

  • In identify-slow-queries.md, resolve both conflict blocks. Keep one Related system variables section and one tidb_slow_log_max_per_sec entry. Match the anchor and version label to the resolved definition in system-variables.md.
  • In TOC-tidb-cloud-premium.md, keep the intended entries and remove all conflict markers.
Committable replacement for the Premium TOC
-<<<<<<< HEAD
-=======
  - [`ANALYZE` Embedded in DDL Statements](/ddl_embedded_analyze.md)
  - [Configure Trigger Rules for Slow Queries](/config-slow-query-trigger-rules.md)
->>>>>>> 8876be1aaa (docs: add a guide for configuring slow query trigger rules (`#23767`))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<<<<<<< HEAD
- [`ANALYZE` Embedded in DDL Statements](/ddl_embedded_analyze.md)
- [Configure Trigger Rules for Slow Queries](/config-slow-query-trigger-rules.md)
📍 Affects 2 files
  • identify-slow-queries.md#L191-L191 (this comment)
  • identify-slow-queries.md#L318-L334
  • TOC-tidb-cloud-premium.md#L564-L568

Sources: Path instructions, Linters/SAST tools

Comment thread system-variables.md
>
> If the character check is skipped, TiDB might fail to detect invalid UTF-8 characters written by the application, cause decoding errors when `ANALYZE` is executed, and introduce other unknown encoding issues. If your application cannot guarantee the validity of the written string, it is not recommended to skip the character check.

<<<<<<< HEAD

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Resolve the merge-conflict markers before merging.

The file still contains conflict markers at lines 6109-6117, 6128-6136, and 6156-6170. The rendered documentation will contain unresolved text and competing headings, anchors, and platform descriptions. Merge the two versions and remove every marker.

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

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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-master This PR is cherry-picked to master from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants