Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions sql-plan-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,22 @@ SHOW binding_cache status;
1 row in set (0.00 sec)
```

### Binding usage

Binding Usage helps you collect usage statistics of SQL bindings, which can assist you in identifying and managing unused bindings. You can use these statistics to optimize your binding management strategy, such as removing bindings that are no longer needed or adjusting existing bindings to improve query performance.

You can use the `tidb_enable_binding_usage` system variable to control whether to enable the usage statistics collection for SQL plan bindings. When this variable is set to `ON`, every six hours, the usage of bindinfo will be written into TiKV.
Comment on lines +483 to +485

Choose a reason for hiding this comment

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

low

This suggestion improves clarity and conciseness. It also uses active voice as recommended by the style guide1 and clarifies that the usage information is written to the mysql.bind_info table.

Suggested change
Binding Usage helps you collect usage statistics of SQL bindings, which can assist you in identifying and managing unused bindings. You can use these statistics to optimize your binding management strategy, such as removing bindings that are no longer needed or adjusting existing bindings to improve query performance.
You can use the `tidb_enable_binding_usage` system variable to control whether to enable the usage statistics collection for SQL plan bindings. When this variable is set to `ON`, every six hours, the usage of bindinfo will be written into TiKV.
The binding usage feature helps you collect usage statistics for SQL bindings. You can use these statistics to identify and manage unused bindings, for example, by removing bindings that are no longer needed or adjusting existing ones to improve query performance.
You can use the `tidb_enable_binding_usage` system variable to control the collection of usage statistics for SQL plan bindings. When this variable is set to `ON`, TiDB writes the binding usage information to the `mysql.bind_info` table every six hours.

Style Guide References

Footnotes

  1. The style guide recommends avoiding overuse of passive voice.


```sql
select sql_digest,last_used_date from mysql.bind_info limit 1;

Choose a reason for hiding this comment

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

low

For consistency with other examples in this document, SQL keywords should be in uppercase. Also, this removes an extra space after from.

Suggested change
select sql_digest,last_used_date from mysql.bind_info limit 1;
SELECT sql_digest, last_used_date FROM mysql.bind_info LIMIT 1;


+------------------------------------------------------------------+----------------+
| sql_digest | last_used_date |
+------------------------------------------------------------------+----------------+
| 5d3975ef2160c1e0517353798dac90a9914095d82c025e7cd97bd55aeb804798 | 2026-10-21 |
+------------------------------------------------------------------+----------------+
```

## Utilize the statement summary table to obtain queries that need to be bound

[Statement summary](/statement-summary-tables.md) records recent SQL execution information, such as latency, execution times, and corresponding query plans. You can query statement summary tables to get qualified `plan_digest`, and then [create bindings according to these historical execution plans](/sql-plan-management.md#create-a-binding-according-to-a-historical-execution-plan).
Expand Down