You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: statement-summary-tables.md
-7Lines changed: 0 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,7 +87,6 @@ The following is a sample output of querying `statements_summary`:
87
87
>
88
88
> - In TiDB, the time unit of fields in statement summary tables is nanosecond (ns), whereas in MySQL the time unit is picosecond (ps).
89
89
> - Starting from v7.5.1 and v7.6.0, for clusters with [resource control](/tidb-resource-control-ru-groups.md) enabled, `statements_summary` will be aggregated by resource group, for example, the same statements executed in different resource groups will be collected as different records.
90
-
> - For TiDB Self-Managed, starting from v9.0.0, you can use [`tidb_stmt_summary_group_by_user`](/system-variables.md#tidb_stmt_summary_group_by_user) to control whether to aggregate statement summaries by execution user. When this variable is set to `ON`, TiDB aggregates the same SQL digest executed by different users into separate records, and the `SAMPLE_USER` field of each record indicates the user who executed the statement. <CustomContentplatform="tidb-cloud"plan="essential,premium">For TiDB Cloud Essential and Premium, `tidb_stmt_summary_group_by_user` is `ON` by default, and it is read-only.</CustomContent>
91
90
92
91
## `statements_summary_history`
93
92
@@ -145,8 +144,6 @@ The following system variables are used to control the statement summary:
145
144
146
145
-`tidb_stmt_summary_max_sql_length`: Specifies the longest display length of `DIGEST_TEXT` and `QUERY_SAMPLE_TEXT`. The default value is `4096`.
147
146
-`tidb_stmt_summary_internal_query`: Determines whether to count the TiDB SQL statements. `1` means to count, and `0` means not to count. The default value is `0`.
148
-
-`tidb_stmt_summary_group_by_user`: Determines whether to aggregate statement summaries by execution user. `1` means to aggregate by user, and `0` means not to aggregate by user. The default value is `0` for TiDB Self-Managed and TiDB Cloud Dedicated, and `1` for TiDB Cloud Essential and Premium. After you enable this variable, TiDB aggregates the same SQL digest executed by different users into separate rows, which might increase the number of statement summary records and memory usage. Modifying this variable clears the current in-memory statement summary data.
149
-
-`tidb_stmt_summary_persist_evicted`: Determines whether to write statement summary records evicted by LRU to the statement summary log after you enable [statements summary persistence](#persist-statements-summary). `1` means to write, and `0` means not to write. The default value is `0`. After you enable this variable, the log contains JSON records marked with `"evicted": true`, and the log volume increases as LRU evictions become more frequent.
150
147
151
148
An example of the statement summary configuration is shown as follows:
152
149
@@ -267,10 +264,6 @@ After statements summary persistence is enabled, the memory keeps only the curre
267
264
268
265
</CustomContent>
269
266
270
-
> **Note:**
271
-
>
272
-
> For TiDB Self-Managed, starting from v9.0.0, you can enable [`tidb_stmt_summary_persist_evicted`](/system-variables.md#tidb_stmt_summary_persist_evicted) to write records evicted by LRU to the statement summary log. TiDB marks these JSON records with `"evicted": true` so that downstream log consumers can identify them. TiDB does not return these records as query results from `statements_summary_history` or `cluster_statements_summary_history`. <CustomContentplatform="tidb-cloud"plan="essential,premium">For TiDB Cloud Essential and Premium, `tidb_stmt_summary_persist_evicted` is read-only.</CustomContent>
273
-
274
267
## Troubleshooting examples
275
268
276
269
This section provides two examples to show how to use the statement summary feature to troubleshoot SQL performance issues.
Copy file name to clipboardExpand all lines: system-variables.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6254,7 +6254,9 @@ For details, see [Identify Slow Queries](/identify-slow-queries.md).
6254
6254
6255
6255
</CustomContent>
6256
6256
6257
-
### tidb_stmt_summary_group_by_user <span class="version-mark">New in v9.0.0 and CLOUD.202603.1</span> {#tidb_stmt_summary_group_by_user}
6257
+
<CustomContent platform="tidb-cloud">
6258
+
6259
+
### tidb_stmt_summary_group_by_user <span class="version-mark">New in CLOUD.202603.1</span> {#tidb_stmt_summary_group_by_user}
6258
6260
6259
6261
> **Note:**
6260
6262
>
@@ -6265,11 +6267,13 @@ For details, see [Identify Slow Queries](/identify-slow-queries.md).
6265
6267
- Persists to cluster: Yes
6266
6268
- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No
6267
6269
- Type: Boolean
6268
-
- Default value: `OFF` for TiDB Self-Managed and TiDB Cloud Dedicated; `ON` for TiDB Cloud Essential and TiDB Cloud Premium
6270
+
- Default value: `ON` for TiDB Cloud Essential and TiDB Cloud Premium
6269
6271
- This variable controls whether to include the user who executes SQL statements as an aggregation dimension in [statement summary tables](/statement-summary-tables.md). When this variable is set to `OFF`, TiDB aggregates the same SQL digest executed by different users into the same row, and the `SAMPLE_USER` field displays one sampled user. When this variable is set to `ON`, TiDB aggregates the same SQL digest executed by different users into separate rows, and the `SAMPLE_USER` field of each row indicates the user who executed the statement.
6270
6272
- Modifying this variable clears the current in-memory statement summary data because data before and after the modification is aggregated using different dimensions. This does not affect historical data persisted to disk.
6271
6273
- After you enable this variable, the number of statement summary records might increase with the number of different execution users for the same SQL digest, which increases memory usage.
6272
6274
6275
+
</CustomContent>
6276
+
6273
6277
### tidb_stmt_summary_history_size <span class="version-mark">New in v4.0</span>
6274
6278
6275
6279
> **Note:**
@@ -6345,7 +6349,9 @@ For details, see [Identify Slow Queries](/identify-slow-queries.md).
6345
6349
6346
6350
</CustomContent>
6347
6351
6348
-
### tidb_stmt_summary_persist_evicted <span class="version-mark">New in v9.0.0 and CLOUD.202603.1</span> {#tidb_stmt_summary_persist_evicted}
6352
+
<CustomContent platform="tidb-cloud">
6353
+
6354
+
### tidb_stmt_summary_persist_evicted <span class="version-mark">New in CLOUD.202603.1</span> {#tidb_stmt_summary_persist_evicted}
6349
6355
6350
6356
> **Note:**
6351
6357
>
@@ -6361,6 +6367,8 @@ For details, see [Identify Slow Queries](/identify-slow-queries.md).
6361
6367
- This variable takes effect only when [tidb_stmt_summary_enable_persistent](/system-variables.md#tidb_stmt_summary_enable_persistent-new-in-v660) is enabled. TiDB does not return records marked with `"evicted": true` as query results from `statements_summary_history` or `cluster_statements_summary_history`.
6362
6368
- After you enable this variable, the log volume increases as LRU evictions become more frequent. TiDB writes evicted records using an asynchronous buffer mechanism. When the buffer queue is full, TiDB might drop new evicted records.
6363
6369
6370
+
</CustomContent>
6371
+
6364
6372
### tidb_stmt_summary_refresh_interval <span class="version-mark">New in v4.0</span>
0 commit comments