Skip to content
Open
Changes from 3 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

The binding usage feature collects usage statistics of SQL plan bindings. You can use these statistics to identify unused bindings and 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 the collection of binding usage statistics. When it is set to `ON`, TiDB writes the binding usage statistics to the `mysql.bind_info` table every six hours.

```sql
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
Loading