Skip to content

Conversation

@qiancai
Copy link
Owner

@qiancai qiancai commented Nov 12, 2025

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 (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)
  • 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

Summary by CodeRabbit

  • Documentation
    • Added documentation for the new tidb_opt_selectivity_factor system variable (v9.0.0) with configuration details including scope, persistence settings, type constraints, range, and default value.

@gemini-code-assist
Copy link

Summary of Changes

Hello @qiancai, 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 new file, temp.md, containing a simple test string. While the title suggests an update to system-variables.md, the actual changes are limited to the new temp.md file. The PR description template is largely unfilled, indicating this might be a placeholder or an initial test submission, possibly related to a translation effort mentioned in the description.

Highlights

  • New File Added: A new file named temp.md has been introduced to the repository.
  • Content of New File: The temp.md file contains a single line of text: "This is a test file.".
  • Discrepancy with Title: The pull request title "Update system-variables.md" does not align with the actual changes, which only involve the addition of temp.md.
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 a file named temp.md that appears to be a test file, as its content is simply "This is a test file.". This file seems unsuitable for the documentation. Furthermore, the pull request title, "Update system-variables.md", does not match the changes in this PR. Please clarify the purpose of this pull request; if it was created by mistake, it should be closed.

Synced from: qiancai/docs-cn#16
Target PR: #51
AI Provider: gemini

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@github-actions
Copy link

Auto-sync completed successfully

Source PR: qiancai/docs-cn#16
Target PR: #51
English documentation has been updated based on Chinese documentation changes.

@coderabbitai
Copy link

coderabbitai bot commented Nov 12, 2025

Walkthrough

A new system variable tidb_opt_selectivity_factor was introduced in TiDB v9.0.0 and documented in the system variables guide. The variable specifies the default selectivity factor applied by the optimizer when statistics cannot determine predicate selectivity, with a floating-point value range of [0, 1] and default value of 0.8.

Changes

Cohort / File(s) Summary
System Variable Documentation
system-variables.md
Added documentation for new system variable tidb_opt_selectivity_factor (v9.0.0), including scope (session/global), persistence settings, and default value (0.8); entries appear in two locations with minor wording variations

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Duplication concern: Verify whether the variable documentation should appear in both locations or if one instance should be removed
  • Consistency check: Ensure wording differences between the two entries are intentional or standardized

Poem

🐰 A new factor hops into view,
Selectivity balanced at point-eight-oh too!
When stats hide their secrets away,
This variable guides the optimizer's way! 🎯✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete - the 'What is changed, added or deleted?' section required information is missing, and no TiDB version checkboxes are selected despite the requirement. Fill in the 'What is changed, added or deleted?' section with details about adding tidb_opt_selectivity_factor, and select appropriate version checkbox(es) (at minimum v9.0 and/or master).
Title check ❓ Inconclusive The title 'Update system-variables.md' is vague and generic, lacking specificity about what was actually changed or added to the file. Replace with a more descriptive title that specifies the change, such as 'Add tidb_opt_selectivity_factor system variable' or 'Document new optimizer selectivity control variable'.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test1112-16

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

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 details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2ebd64 and 1441d5d.

📒 Files selected for processing (1)
  • system-variables.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.md

⚙️ CodeRabbit configuration file

As a technical writer in the database area, you need to first learn the changes in this PR, and then improve the content to make it clear, concise, and easy to understand in English according to your database knowledge.

Files:

  • system-variables.md

Comment on lines +1795 to +1804
### `tidb_opt_selectivity_factor` <span class="version-mark">Introduced in v9.0.0</span>
- Scope: SESSION | GLOBAL
- Persist to cluster: Yes
- Controlled by hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): Yes
- Type: Floating-point number
- Value range: `[0, 1]`
- Default value: `0.8`
- This variable specifies the default selectivity of the TiDB optimizer. In some cases, when the optimizer cannot derive the predicate selectivity based on statistics, the optimizer uses this default selectivity as an alternative value. **We do not recommend** modifying this value.
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Align wording with house style; tighten description; consider relocating under tidb_opt_ block*

  • Use “New in v9.0.0”, “Persists to cluster”, “Applies to hint [SET_VAR]”, type “Float”, and label “Range” to match conventions.
  • Prefer the stronger “It is NOT recommended to modify this variable.” used elsewhere.
  • Optional: Move this entry down to the tidb_opt_* section to keep variables grouped consistently.
-### `tidb_opt_selectivity_factor` <span class="version-mark">Introduced in v9.0.0</span>
+### `tidb_opt_selectivity_factor` <span class="version-mark">New in v9.0.0</span>
 
 - Scope: SESSION | GLOBAL
-- Persist to cluster: Yes
-- Controlled by hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): Yes
-- Type: Floating-point number
-- Value range: `[0, 1]`
+- Persists to cluster: Yes
+- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): Yes
+- Type: Float
+- Range: `[0, 1]`
 - Default value: `0.8`
-- This variable specifies the default selectivity of the TiDB optimizer. In some cases, when the optimizer cannot derive the predicate selectivity based on statistics, the optimizer uses this default selectivity as an alternative value. **We do not recommend** modifying this value.
+- Specifies the default predicate selectivity the optimizer uses when statistics cannot estimate selectivity (for example, complex expressions or missing stats). Lower values assume more selective predicates and influence cardinality estimates and plan choices. It is NOT recommended to modify this value; instead, prefer improving statistics collection.

To ensure no duplicate entries slipped in, please run:


🏁 Script executed:

#!/bin/bash
rg -n "tidb_opt_selectivity_factor" system-variables.md -C2

Length of output: 436


I need to verify whether the suggested conventions in the review comment actually match the file's established style. Let me check the documentation patterns:


🏁 Script executed:

#!/bin/bash
# Check patterns for version markers, type labels, and attribute naming
rg -n "Introduced in|New in" system-variables.md | head -20
rg -n "Persist|Persists" system-variables.md | head -20
rg -n "Floating-point|Float|Integer|Boolean" system-variables.md | head -20
rg -n "Value range|Range:" system-variables.md | head -20
rg -n "Controlled by hint|Applies to hint" system-variables.md | head -20

Length of output: 299



---

🏁 Script executed:

```shell
#!/bin/bash
# Locate the file
fd -t f "system-variables.md" 

Length of output: 19


🏁 Script executed:

#!/bin/bash
# Check patterns for version markers, type labels, and attribute naming
echo "=== Version markers ==="
rg -n "Introduced in|New in" system-variables.md | head -10

echo ""
echo "=== Persist/Persists usage ==="
rg -n "Persist to cluster|Persists to cluster" system-variables.md | head -10

echo ""
echo "=== Type labels ==="
rg -n "Type:.*Floating-point|Type:.*Float|Type:.*Integer|Type:.*Boolean" system-variables.md | head -10

echo ""
echo "=== Range labels ==="
rg -n "Value range|^- Range:" system-variables.md | head -10

echo ""
echo "=== Hint references ==="
rg -n "Controlled by hint|Applies to hint" system-variables.md | head -10

Length of output: 4040


🏁 Script executed:

#!/bin/bash
# Search more broadly for type labels including Floating-point
echo "=== All Floating-point type labels ==="
rg -n "Type: Floating-point" system-variables.md

echo ""
echo "=== All Float type labels ==="
rg -n "Type: Float" system-variables.md

echo ""
echo "=== Find tidb_opt_ variables ==="
rg -n "tidb_opt_" system-variables.md | head -20

echo ""
echo "=== Recommendation phrasing patterns ==="
rg -n "NOT recommended|do not recommend|We do not recommend|It is NOT" system-variables.md | head -10

Length of output: 4273


Fix style inconsistencies: use "New", "Persists to cluster", "Applies to hint", "Float", "Range", and "It is NOT recommended"

Multiple attributes do not match established file conventions:

  • Version marker: "Introduced in" should be "New in" (see lines 55, 64, 74, etc.)
  • Persist attribute: "Persist to cluster" should be "Persists to cluster" (see lines 58, 67, 77, etc.)
  • Hint attribute: "Controlled by hint" should be "Applies to hint" (see lines 59, 68, 78, etc.)
  • Type: "Floating-point number" should be "Float" (see line 1260, 1810, 3454, and 40+ other occurrences)
  • Attribute: "Value range" should be "Range" (see lines 117, 127, 146, etc.)
  • Recommendation: "We do not recommend" should be "It is NOT recommended" (see lines 339, 371, 2334, etc.)

Optional: Move this entry to the tidb_opt_* variables section around line 4153 for consistency with other optimizer settings.

-### `tidb_opt_selectivity_factor` <span class="version-mark">Introduced in v9.0.0</span>
+### `tidb_opt_selectivity_factor` <span class="version-mark">New in v9.0.0</span>
 
 - Scope: SESSION | GLOBAL
-- Persist to cluster: Yes
-- Controlled by hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): Yes
-- Type: Floating-point number
-- Value range: `[0, 1]`
+- Persists to cluster: Yes
+- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): Yes
+- Type: Float
+- Range: `[0, 1]`
 - Default value: `0.8`
-- This variable specifies the default selectivity of the TiDB optimizer. In some cases, when the optimizer cannot derive the predicate selectivity based on statistics, the optimizer uses this default selectivity as an alternative value. **We do not recommend** modifying this value.
+- This variable specifies the default selectivity of the TiDB optimizer. In some cases, when the optimizer cannot derive the predicate selectivity based on statistics, the optimizer uses this default selectivity as an alternative value. **It is NOT recommended** to modify this value.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants