From 243233dfce2cba1acf4f4b458cbabcea15531421 Mon Sep 17 00:00:00 2001 From: Jiong <2301210292@stu.pku.edu.cn> Date: Mon, 30 Mar 2026 16:05:42 +0800 Subject: [PATCH 1/4] This is an automated cherry-pick of #22547 Signed-off-by: ti-chi-bot --- .../information-schema-slow-query.md | 199 ++++++++++++++++++ ...erformance-schema-session-connect-attrs.md | 15 ++ status-variables.md | 12 ++ system-variable-reference.md | 7 + system-variables.md | 20 ++ 5 files changed, 253 insertions(+) diff --git a/information-schema/information-schema-slow-query.md b/information-schema/information-schema-slow-query.md index 2125213f64308..32335b9671572 100644 --- a/information-schema/information-schema-slow-query.md +++ b/information-schema/information-schema-slow-query.md @@ -35,6 +35,7 @@ DESC SLOW_QUERY; The output is as follows: ```sql +<<<<<<< HEAD +-------------------------------+---------------------+------+------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------------------+---------------------+------+------+---------+-------+ @@ -121,10 +122,109 @@ The output is as follows: | Query | longtext | YES | | NULL | | +-------------------------------+---------------------+------+------+---------+-------+ 81 rows in set (0.00 sec) +======= ++--------------------------------------------+-----------------+------+------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++--------------------------------------------+-----------------+------+------+---------+-------+ +| Time | timestamp(6) | NO | PRI | NULL | | +| Txn_start_ts | bigint unsigned | YES | | NULL | | +| User | varchar(64) | YES | | NULL | | +| Host | varchar(64) | YES | | NULL | | +| Conn_ID | bigint unsigned | YES | | NULL | | +| Session_alias | varchar(64) | YES | | NULL | | +| Exec_retry_count | bigint unsigned | YES | | NULL | | +| Exec_retry_time | double | YES | | NULL | | +| Query_time | double | YES | | NULL | | +| Parse_time | double | YES | | NULL | | +| Compile_time | double | YES | | NULL | | +| Rewrite_time | double | YES | | NULL | | +| Preproc_subqueries | bigint unsigned | YES | | NULL | | +| Preproc_subqueries_time | double | YES | | NULL | | +| Optimize_time | double | YES | | NULL | | +| Wait_TS | double | YES | | NULL | | +| Prewrite_time | double | YES | | NULL | | +| Wait_prewrite_binlog_time | double | YES | | NULL | | +| Commit_time | double | YES | | NULL | | +| Get_commit_ts_time | double | YES | | NULL | | +| Commit_backoff_time | double | YES | | NULL | | +| Backoff_types | varchar(64) | YES | | NULL | | +| Resolve_lock_time | double | YES | | NULL | | +| Local_latch_wait_time | double | YES | | NULL | | +| Write_keys | bigint | YES | | NULL | | +| Write_size | bigint | YES | | NULL | | +| Prewrite_region | bigint | YES | | NULL | | +| Txn_retry | bigint | YES | | NULL | | +| Cop_time | double | YES | | NULL | | +| Process_time | double | YES | | NULL | | +| Wait_time | double | YES | | NULL | | +| Backoff_time | double | YES | | NULL | | +| LockKeys_time | double | YES | | NULL | | +| Request_count | bigint unsigned | YES | | NULL | | +| Total_keys | bigint unsigned | YES | | NULL | | +| Process_keys | bigint unsigned | YES | | NULL | | +| Rocksdb_delete_skipped_count | bigint unsigned | YES | | NULL | | +| Rocksdb_key_skipped_count | bigint unsigned | YES | | NULL | | +| Rocksdb_block_cache_hit_count | bigint unsigned | YES | | NULL | | +| Rocksdb_block_read_count | bigint unsigned | YES | | NULL | | +| Rocksdb_block_read_byte | bigint unsigned | YES | | NULL | | +| DB | varchar(64) | YES | | NULL | | +| Index_names | varchar(100) | YES | | NULL | | +| Is_internal | tinyint(1) | YES | | NULL | | +| Digest | varchar(64) | YES | | NULL | | +| Stats | varchar(512) | YES | | NULL | | +| Cop_proc_avg | double | YES | | NULL | | +| Cop_proc_p90 | double | YES | | NULL | | +| Cop_proc_max | double | YES | | NULL | | +| Cop_proc_addr | varchar(64) | YES | | NULL | | +| Cop_wait_avg | double | YES | | NULL | | +| Cop_wait_p90 | double | YES | | NULL | | +| Cop_wait_max | double | YES | | NULL | | +| Cop_wait_addr | varchar(64) | YES | | NULL | | +| Mem_max | bigint | YES | | NULL | | +| Disk_max | bigint | YES | | NULL | | +| KV_total | double | YES | | NULL | | +| PD_total | double | YES | | NULL | | +| Backoff_total | double | YES | | NULL | | +| Unpacked_bytes_sent_tikv_total | bigint | YES | | NULL | | +| Unpacked_bytes_received_tikv_total | bigint | YES | | NULL | | +| Unpacked_bytes_sent_tikv_cross_zone | bigint | YES | | NULL | | +| Unpacked_bytes_received_tikv_cross_zone | bigint | YES | | NULL | | +| Unpacked_bytes_sent_tiflash_total | bigint | YES | | NULL | | +| Unpacked_bytes_received_tiflash_total | bigint | YES | | NULL | | +| Unpacked_bytes_sent_tiflash_cross_zone | bigint | YES | | NULL | | +| Unpacked_bytes_received_tiflash_cross_zone | bigint | YES | | NULL | | +| Write_sql_response_total | double | YES | | NULL | | +| Result_rows | bigint | YES | | NULL | | +| Warnings | longtext | YES | | NULL | | +| Backoff_Detail | varchar(4096) | YES | | NULL | | +| Prepared | tinyint(1) | YES | | NULL | | +| Succ | tinyint(1) | YES | | NULL | | +| IsExplicitTxn | tinyint(1) | YES | | NULL | | +| IsWriteCacheTable | tinyint(1) | YES | | NULL | | +| Plan_from_cache | tinyint(1) | YES | | NULL | | +| Plan_from_binding | tinyint(1) | YES | | NULL | | +| Has_more_results | tinyint(1) | YES | | NULL | | +| Resource_group | varchar(64) | YES | | NULL | | +| Request_unit_read | double | YES | | NULL | | +| Request_unit_write | double | YES | | NULL | | +| Time_queued_by_rc | double | YES | | NULL | | +| Tidb_cpu_time | double | YES | | NULL | | +| Tikv_cpu_time | double | YES | | NULL | | +| Plan | longtext | YES | | NULL | | +| Plan_digest | varchar(128) | YES | | NULL | | +| Binary_plan | longtext | YES | | NULL | | +| Prev_stmt | longtext | YES | | NULL | | +| Session_connect_attrs | json | YES | | NULL | | +| Query | longtext | YES | | NULL | | ++--------------------------------------------+-----------------+------+------+---------+-------+ +90 rows in set (0.00 sec) +>>>>>>> 5c91200b1f (docs: support logging session connect attrs to slow query log (#22547)) ``` The maximum statement length of the `Query` column is limited by the [`tidb_stmt_summary_max_sql_length`](/system-variables.md#tidb_stmt_summary_max_sql_length-new-in-v40) system variable. +The `Session_connect_attrs` column stores session connection attributes in JSON format parsed from the slow log. TiDB controls the maximum payload size written to this field using [`performance_schema_session_connect_attrs_size`](/system-variables.md#performance_schema_session_connect_attrs_size-new-in-v900). + ## CLUSTER_SLOW_QUERY table The `CLUSTER_SLOW_QUERY` table provides the slow query information of all nodes in the cluster, which is the parsing result of the TiDB slow log files. You can use the `CLUSTER_SLOW_QUERY` table the way you do with `SLOW_QUERY`. The table schema of the `CLUSTER_SLOW_QUERY` table differs from that of the `SLOW_QUERY` table in that an `INSTANCE` column is added to `CLUSTER_SLOW_QUERY`. The `INSTANCE` column represents the TiDB node address of the row information on the slow query. @@ -146,6 +246,7 @@ DESC CLUSTER_SLOW_QUERY; The output is as follows: ```sql +<<<<<<< HEAD +-------------------------------+---------------------+------+------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------------------+---------------------+------+------+---------+-------+ @@ -233,6 +334,104 @@ The output is as follows: | Query | longtext | YES | | NULL | | +-------------------------------+---------------------+------+------+---------+-------+ 82 rows in set (0.00 sec) +======= ++--------------------------------------------+-----------------+------+------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++--------------------------------------------+-----------------+------+------+---------+-------+ +| INSTANCE | varchar(64) | YES | | NULL | | +| Time | timestamp(6) | NO | PRI | NULL | | +| Txn_start_ts | bigint unsigned | YES | | NULL | | +| User | varchar(64) | YES | | NULL | | +| Host | varchar(64) | YES | | NULL | | +| Conn_ID | bigint unsigned | YES | | NULL | | +| Session_alias | varchar(64) | YES | | NULL | | +| Exec_retry_count | bigint unsigned | YES | | NULL | | +| Exec_retry_time | double | YES | | NULL | | +| Query_time | double | YES | | NULL | | +| Parse_time | double | YES | | NULL | | +| Compile_time | double | YES | | NULL | | +| Rewrite_time | double | YES | | NULL | | +| Preproc_subqueries | bigint unsigned | YES | | NULL | | +| Preproc_subqueries_time | double | YES | | NULL | | +| Optimize_time | double | YES | | NULL | | +| Wait_TS | double | YES | | NULL | | +| Prewrite_time | double | YES | | NULL | | +| Wait_prewrite_binlog_time | double | YES | | NULL | | +| Commit_time | double | YES | | NULL | | +| Get_commit_ts_time | double | YES | | NULL | | +| Commit_backoff_time | double | YES | | NULL | | +| Backoff_types | varchar(64) | YES | | NULL | | +| Resolve_lock_time | double | YES | | NULL | | +| Local_latch_wait_time | double | YES | | NULL | | +| Write_keys | bigint | YES | | NULL | | +| Write_size | bigint | YES | | NULL | | +| Prewrite_region | bigint | YES | | NULL | | +| Txn_retry | bigint | YES | | NULL | | +| Cop_time | double | YES | | NULL | | +| Process_time | double | YES | | NULL | | +| Wait_time | double | YES | | NULL | | +| Backoff_time | double | YES | | NULL | | +| LockKeys_time | double | YES | | NULL | | +| Request_count | bigint unsigned | YES | | NULL | | +| Total_keys | bigint unsigned | YES | | NULL | | +| Process_keys | bigint unsigned | YES | | NULL | | +| Rocksdb_delete_skipped_count | bigint unsigned | YES | | NULL | | +| Rocksdb_key_skipped_count | bigint unsigned | YES | | NULL | | +| Rocksdb_block_cache_hit_count | bigint unsigned | YES | | NULL | | +| Rocksdb_block_read_count | bigint unsigned | YES | | NULL | | +| Rocksdb_block_read_byte | bigint unsigned | YES | | NULL | | +| DB | varchar(64) | YES | | NULL | | +| Index_names | varchar(100) | YES | | NULL | | +| Is_internal | tinyint(1) | YES | | NULL | | +| Digest | varchar(64) | YES | | NULL | | +| Stats | varchar(512) | YES | | NULL | | +| Cop_proc_avg | double | YES | | NULL | | +| Cop_proc_p90 | double | YES | | NULL | | +| Cop_proc_max | double | YES | | NULL | | +| Cop_proc_addr | varchar(64) | YES | | NULL | | +| Cop_wait_avg | double | YES | | NULL | | +| Cop_wait_p90 | double | YES | | NULL | | +| Cop_wait_max | double | YES | | NULL | | +| Cop_wait_addr | varchar(64) | YES | | NULL | | +| Mem_max | bigint | YES | | NULL | | +| Disk_max | bigint | YES | | NULL | | +| KV_total | double | YES | | NULL | | +| PD_total | double | YES | | NULL | | +| Backoff_total | double | YES | | NULL | | +| Unpacked_bytes_sent_tikv_total | bigint | YES | | NULL | | +| Unpacked_bytes_received_tikv_total | bigint | YES | | NULL | | +| Unpacked_bytes_sent_tikv_cross_zone | bigint | YES | | NULL | | +| Unpacked_bytes_received_tikv_cross_zone | bigint | YES | | NULL | | +| Unpacked_bytes_sent_tiflash_total | bigint | YES | | NULL | | +| Unpacked_bytes_received_tiflash_total | bigint | YES | | NULL | | +| Unpacked_bytes_sent_tiflash_cross_zone | bigint | YES | | NULL | | +| Unpacked_bytes_received_tiflash_cross_zone | bigint | YES | | NULL | | +| Write_sql_response_total | double | YES | | NULL | | +| Result_rows | bigint | YES | | NULL | | +| Warnings | longtext | YES | | NULL | | +| Backoff_Detail | varchar(4096) | YES | | NULL | | +| Prepared | tinyint(1) | YES | | NULL | | +| Succ | tinyint(1) | YES | | NULL | | +| IsExplicitTxn | tinyint(1) | YES | | NULL | | +| IsWriteCacheTable | tinyint(1) | YES | | NULL | | +| Plan_from_cache | tinyint(1) | YES | | NULL | | +| Plan_from_binding | tinyint(1) | YES | | NULL | | +| Has_more_results | tinyint(1) | YES | | NULL | | +| Resource_group | varchar(64) | YES | | NULL | | +| Request_unit_read | double | YES | | NULL | | +| Request_unit_write | double | YES | | NULL | | +| Time_queued_by_rc | double | YES | | NULL | | +| Tidb_cpu_time | double | YES | | NULL | | +| Tikv_cpu_time | double | YES | | NULL | | +| Plan | longtext | YES | | NULL | | +| Plan_digest | varchar(128) | YES | | NULL | | +| Binary_plan | longtext | YES | | NULL | | +| Prev_stmt | longtext | YES | | NULL | | +| Session_connect_attrs | json | YES | | NULL | | +| Query | longtext | YES | | NULL | | ++--------------------------------------------+-----------------+------+------+---------+-------+ +91 rows in set (0.00 sec) +>>>>>>> 5c91200b1f (docs: support logging session connect attrs to slow query log (#22547)) ``` When the cluster system table is queried, TiDB does not obtain data from all nodes, but pushes down the related calculation to other nodes. The execution plan is as follows: diff --git a/performance-schema/performance-schema-session-connect-attrs.md b/performance-schema/performance-schema-session-connect-attrs.md index eb2da52e2d426..02a793bfb953d 100644 --- a/performance-schema/performance-schema-session-connect-attrs.md +++ b/performance-schema/performance-schema-session-connect-attrs.md @@ -66,3 +66,18 @@ Fields in the `SESSION_CONNECT_ATTRS` table are described as follows: * `ATTR_NAME`: Attribute name. * `ATTR_VALUE`: Attribute value. * `ORDINAL_POSITION`: Ordinal position of the name/value pair. + +## Size limit and truncation + +TiDB uses the [`performance_schema_session_connect_attrs_size`](/system-variables.md#performance_schema_session_connect_attrs_size-new-in-v900) global system variable to control the maximum total size of connection attributes per session. + +- Default value: `4096` bytes +- Range: `[-1, 65536]` +- `-1` means no configured limit, and TiDB treats it as up to `65536` bytes. +- `0` means that TiDB does not retain client-provided session connection attributes, which effectively disables recording session attributes. + +When the total size exceeds this limit, TiDB truncates excess attributes and adds `_truncated` to indicate the number of truncated bytes. + +The accepted connection attributes are also written to the `Session_connect_attrs` field in the slow log and can be queried from [`INFORMATION_SCHEMA.SLOW_QUERY`](/information-schema/information-schema-slow-query.md) and `INFORMATION_SCHEMA.CLUSTER_SLOW_QUERY`. To control the payload size written to the slow log, adjust `performance_schema_session_connect_attrs_size`. + +TiDB also enforces a hard limit of 1 MiB on connection attribute payload in handshake packets. If this hard limit is exceeded, the connection is rejected. diff --git a/status-variables.md b/status-variables.md index ec577d88c6173..ec07a6e52e2bf 100644 --- a/status-variables.md +++ b/status-variables.md @@ -31,6 +31,18 @@ Additionally, the [FLUSH STATUS](/sql-statements/sql-statement-flush-status.md) - Type: Integer - The compression level that is used for the MySQL Protocol. +### Performance_schema_session_connect_attrs_longest_seen + +- Scope: GLOBAL +- Type: Integer +- The largest total size (in bytes) of session connection attributes observed by TiDB. + +### Performance_schema_session_connect_attrs_lost + +- Scope: GLOBAL +- Type: Integer +- The number of sessions whose connection attributes were truncated due to `performance_schema_session_connect_attrs_size`. + ### Ssl_cipher - Scope: SESSION | GLOBAL diff --git a/system-variable-reference.md b/system-variable-reference.md index c6f179d0efec5..f6e845fb3d11c 100644 --- a/system-variable-reference.md +++ b/system-variable-reference.md @@ -594,6 +594,13 @@ Referenced in: - [TiDB 8.5.0 Release Notes](/releases/release-8.5.0.md) - [TiDB 7.6.0 Release Notes](/releases/release-7.6.0.md) +### performance_schema_session_connect_attrs_size + +Referenced in: + +- [`SESSION_CONNECT_ATTRS`](/performance-schema/performance-schema-session-connect-attrs.md) +- [System Variables](/system-variables.md#performance_schema_session_connect_attrs_size-new-in-v900) + ### plugin_dir Referenced in: diff --git a/system-variables.md b/system-variables.md index 961c8d1ed075b..bfdbfbaf056dd 100644 --- a/system-variables.md +++ b/system-variables.md @@ -794,6 +794,26 @@ mysql> SHOW GLOBAL VARIABLES LIKE 'max_prepared_stmt_count'; * In a cluster with a large number of Regions, the PD leader experiences high CPU pressure due to the increased overhead of handling heartbeats and scheduling tasks. * In a TiDB cluster with many TiDB instances, the PD leader experiences high CPU pressure due to a high concurrency of requests for Region information. +### performance_schema_session_connect_attrs_size New in v9.0.0 + +- Scope: GLOBAL +- Persists to cluster: Yes +- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No +- Type: Integer +- Default value: `4096` +- Range: `[-1, 65536]` +- Unit: Bytes +- Controls the maximum total size of connection attributes for each session. +- If the total size of connection attributes exceeds this value, TiDB truncates excess attributes and adds `_truncated` to indicate the number of truncated bytes. +- Connection attributes accepted within this limit are written to the `Session_connect_attrs` field in the slow log and can be queried from [`INFORMATION_SCHEMA.SLOW_QUERY`](/information-schema/information-schema-slow-query.md) and `INFORMATION_SCHEMA.CLUSTER_SLOW_QUERY`. +- You can control the size of `Session_connect_attrs` recorded in the slow log by adjusting this variable. +- If the value is set to `-1`, this means the limit is not configured and TiDB treats it as up to `65536` bytes. +- If the value is set to `0`, TiDB does not retain client-provided session connection attributes, which effectively disables recording session attributes. + +> **Note:** +> +> TiDB enforces a hard limit of 1 MiB for handshake connection attributes. If this hard limit is exceeded, the connection is rejected. + ### plugin_dir > **Note:** From 43bca0645058aa766da03c8715adb700a3edca03 Mon Sep 17 00:00:00 2001 From: yibin87 Date: Fri, 17 Apr 2026 12:58:52 +0800 Subject: [PATCH 2/4] docs: resolve slow query conflict --- .../information-schema-slow-query.md | 179 ------------------ 1 file changed, 179 deletions(-) diff --git a/information-schema/information-schema-slow-query.md b/information-schema/information-schema-slow-query.md index 32335b9671572..54e2d740e3cdb 100644 --- a/information-schema/information-schema-slow-query.md +++ b/information-schema/information-schema-slow-query.md @@ -35,94 +35,6 @@ DESC SLOW_QUERY; The output is as follows: ```sql -<<<<<<< HEAD -+-------------------------------+---------------------+------+------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------------------+---------------------+------+------+---------+-------+ -| Time | timestamp(6) | NO | PRI | NULL | | -| Txn_start_ts | bigint(20) unsigned | YES | | NULL | | -| User | varchar(64) | YES | | NULL | | -| Host | varchar(64) | YES | | NULL | | -| Conn_ID | bigint(20) unsigned | YES | | NULL | | -| Session_alias | varchar(64) | YES | | NULL | | -| Exec_retry_count | bigint(20) unsigned | YES | | NULL | | -| Exec_retry_time | double | YES | | NULL | | -| Query_time | double | YES | | NULL | | -| Parse_time | double | YES | | NULL | | -| Compile_time | double | YES | | NULL | | -| Rewrite_time | double | YES | | NULL | | -| Preproc_subqueries | bigint(20) unsigned | YES | | NULL | | -| Preproc_subqueries_time | double | YES | | NULL | | -| Optimize_time | double | YES | | NULL | | -| Wait_TS | double | YES | | NULL | | -| Prewrite_time | double | YES | | NULL | | -| Wait_prewrite_binlog_time | double | YES | | NULL | | -| Commit_time | double | YES | | NULL | | -| Get_commit_ts_time | double | YES | | NULL | | -| Commit_backoff_time | double | YES | | NULL | | -| Backoff_types | varchar(64) | YES | | NULL | | -| Resolve_lock_time | double | YES | | NULL | | -| Local_latch_wait_time | double | YES | | NULL | | -| Write_keys | bigint(22) | YES | | NULL | | -| Write_size | bigint(22) | YES | | NULL | | -| Prewrite_region | bigint(22) | YES | | NULL | | -| Txn_retry | bigint(22) | YES | | NULL | | -| Cop_time | double | YES | | NULL | | -| Process_time | double | YES | | NULL | | -| Wait_time | double | YES | | NULL | | -| Backoff_time | double | YES | | NULL | | -| LockKeys_time | double | YES | | NULL | | -| Request_count | bigint(20) unsigned | YES | | NULL | | -| Total_keys | bigint(20) unsigned | YES | | NULL | | -| Process_keys | bigint(20) unsigned | YES | | NULL | | -| Rocksdb_delete_skipped_count | bigint(20) unsigned | YES | | NULL | | -| Rocksdb_key_skipped_count | bigint(20) unsigned | YES | | NULL | | -| Rocksdb_block_cache_hit_count | bigint(20) unsigned | YES | | NULL | | -| Rocksdb_block_read_count | bigint(20) unsigned | YES | | NULL | | -| Rocksdb_block_read_byte | bigint(20) unsigned | YES | | NULL | | -| DB | varchar(64) | YES | | NULL | | -| Index_names | varchar(100) | YES | | NULL | | -| Is_internal | tinyint(1) | YES | | NULL | | -| Digest | varchar(64) | YES | | NULL | | -| Stats | varchar(512) | YES | | NULL | | -| Cop_proc_avg | double | YES | | NULL | | -| Cop_proc_p90 | double | YES | | NULL | | -| Cop_proc_max | double | YES | | NULL | | -| Cop_proc_addr | varchar(64) | YES | | NULL | | -| Cop_wait_avg | double | YES | | NULL | | -| Cop_wait_p90 | double | YES | | NULL | | -| Cop_wait_max | double | YES | | NULL | | -| Cop_wait_addr | varchar(64) | YES | | NULL | | -| Mem_max | bigint(20) | YES | | NULL | | -| Disk_max | bigint(20) | YES | | NULL | | -| KV_total | double | YES | | NULL | | -| PD_total | double | YES | | NULL | | -| Backoff_total | double | YES | | NULL | | -| Write_sql_response_total | double | YES | | NULL | | -| Result_rows | bigint(22) | YES | | NULL | | -| Warnings | longtext | YES | | NULL | | -| Backoff_Detail | varchar(4096) | YES | | NULL | | -| Prepared | tinyint(1) | YES | | NULL | | -| Succ | tinyint(1) | YES | | NULL | | -| IsExplicitTxn | tinyint(1) | YES | | NULL | | -| IsWriteCacheTable | tinyint(1) | YES | | NULL | | -| Plan_from_cache | tinyint(1) | YES | | NULL | | -| Plan_from_binding | tinyint(1) | YES | | NULL | | -| Has_more_results | tinyint(1) | YES | | NULL | | -| Resource_group | varchar(64) | YES | | NULL | | -| Request_unit_read | double | YES | | NULL | | -| Request_unit_write | double | YES | | NULL | | -| Time_queued_by_rc | double | YES | | NULL | | -| Tidb_cpu_time | double | YES | | NULL | | -| Tikv_cpu_time | double | YES | | NULL | | -| Plan | longtext | YES | | NULL | | -| Plan_digest | varchar(128) | YES | | NULL | | -| Binary_plan | longtext | YES | | NULL | | -| Prev_stmt | longtext | YES | | NULL | | -| Query | longtext | YES | | NULL | | -+-------------------------------+---------------------+------+------+---------+-------+ -81 rows in set (0.00 sec) -======= +--------------------------------------------+-----------------+------+------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------------------------------+-----------------+------+------+---------+-------+ @@ -218,7 +130,6 @@ The output is as follows: | Query | longtext | YES | | NULL | | +--------------------------------------------+-----------------+------+------+---------+-------+ 90 rows in set (0.00 sec) ->>>>>>> 5c91200b1f (docs: support logging session connect attrs to slow query log (#22547)) ``` The maximum statement length of the `Query` column is limited by the [`tidb_stmt_summary_max_sql_length`](/system-variables.md#tidb_stmt_summary_max_sql_length-new-in-v40) system variable. @@ -246,95 +157,6 @@ DESC CLUSTER_SLOW_QUERY; The output is as follows: ```sql -<<<<<<< HEAD -+-------------------------------+---------------------+------+------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------------------+---------------------+------+------+---------+-------+ -| INSTANCE | varchar(64) | YES | | NULL | | -| Time | timestamp(6) | NO | PRI | NULL | | -| Txn_start_ts | bigint(20) unsigned | YES | | NULL | | -| User | varchar(64) | YES | | NULL | | -| Host | varchar(64) | YES | | NULL | | -| Conn_ID | bigint(20) unsigned | YES | | NULL | | -| Session_alias | varchar(64) | YES | | NULL | | -| Exec_retry_count | bigint(20) unsigned | YES | | NULL | | -| Exec_retry_time | double | YES | | NULL | | -| Query_time | double | YES | | NULL | | -| Parse_time | double | YES | | NULL | | -| Compile_time | double | YES | | NULL | | -| Rewrite_time | double | YES | | NULL | | -| Preproc_subqueries | bigint(20) unsigned | YES | | NULL | | -| Preproc_subqueries_time | double | YES | | NULL | | -| Optimize_time | double | YES | | NULL | | -| Wait_TS | double | YES | | NULL | | -| Prewrite_time | double | YES | | NULL | | -| Wait_prewrite_binlog_time | double | YES | | NULL | | -| Commit_time | double | YES | | NULL | | -| Get_commit_ts_time | double | YES | | NULL | | -| Commit_backoff_time | double | YES | | NULL | | -| Backoff_types | varchar(64) | YES | | NULL | | -| Resolve_lock_time | double | YES | | NULL | | -| Local_latch_wait_time | double | YES | | NULL | | -| Write_keys | bigint(22) | YES | | NULL | | -| Write_size | bigint(22) | YES | | NULL | | -| Prewrite_region | bigint(22) | YES | | NULL | | -| Txn_retry | bigint(22) | YES | | NULL | | -| Cop_time | double | YES | | NULL | | -| Process_time | double | YES | | NULL | | -| Wait_time | double | YES | | NULL | | -| Backoff_time | double | YES | | NULL | | -| LockKeys_time | double | YES | | NULL | | -| Request_count | bigint(20) unsigned | YES | | NULL | | -| Total_keys | bigint(20) unsigned | YES | | NULL | | -| Process_keys | bigint(20) unsigned | YES | | NULL | | -| Rocksdb_delete_skipped_count | bigint(20) unsigned | YES | | NULL | | -| Rocksdb_key_skipped_count | bigint(20) unsigned | YES | | NULL | | -| Rocksdb_block_cache_hit_count | bigint(20) unsigned | YES | | NULL | | -| Rocksdb_block_read_count | bigint(20) unsigned | YES | | NULL | | -| Rocksdb_block_read_byte | bigint(20) unsigned | YES | | NULL | | -| DB | varchar(64) | YES | | NULL | | -| Index_names | varchar(100) | YES | | NULL | | -| Is_internal | tinyint(1) | YES | | NULL | | -| Digest | varchar(64) | YES | | NULL | | -| Stats | varchar(512) | YES | | NULL | | -| Cop_proc_avg | double | YES | | NULL | | -| Cop_proc_p90 | double | YES | | NULL | | -| Cop_proc_max | double | YES | | NULL | | -| Cop_proc_addr | varchar(64) | YES | | NULL | | -| Cop_wait_avg | double | YES | | NULL | | -| Cop_wait_p90 | double | YES | | NULL | | -| Cop_wait_max | double | YES | | NULL | | -| Cop_wait_addr | varchar(64) | YES | | NULL | | -| Mem_max | bigint(20) | YES | | NULL | | -| Disk_max | bigint(20) | YES | | NULL | | -| KV_total | double | YES | | NULL | | -| PD_total | double | YES | | NULL | | -| Backoff_total | double | YES | | NULL | | -| Write_sql_response_total | double | YES | | NULL | | -| Result_rows | bigint(22) | YES | | NULL | | -| Warnings | longtext | YES | | NULL | | -| Backoff_Detail | varchar(4096) | YES | | NULL | | -| Prepared | tinyint(1) | YES | | NULL | | -| Succ | tinyint(1) | YES | | NULL | | -| IsExplicitTxn | tinyint(1) | YES | | NULL | | -| IsWriteCacheTable | tinyint(1) | YES | | NULL | | -| Plan_from_cache | tinyint(1) | YES | | NULL | | -| Plan_from_binding | tinyint(1) | YES | | NULL | | -| Has_more_results | tinyint(1) | YES | | NULL | | -| Resource_group | varchar(64) | YES | | NULL | | -| Request_unit_read | double | YES | | NULL | | -| Request_unit_write | double | YES | | NULL | | -| Time_queued_by_rc | double | YES | | NULL | | -| Tidb_cpu_time | double | YES | | NULL | | -| Tikv_cpu_time | double | YES | | NULL | | -| Plan | longtext | YES | | NULL | | -| Plan_digest | varchar(128) | YES | | NULL | | -| Binary_plan | longtext | YES | | NULL | | -| Prev_stmt | longtext | YES | | NULL | | -| Query | longtext | YES | | NULL | | -+-------------------------------+---------------------+------+------+---------+-------+ -82 rows in set (0.00 sec) -======= +--------------------------------------------+-----------------+------+------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------------------------------+-----------------+------+------+---------+-------+ @@ -431,7 +253,6 @@ The output is as follows: | Query | longtext | YES | | NULL | | +--------------------------------------------+-----------------+------+------+---------+-------+ 91 rows in set (0.00 sec) ->>>>>>> 5c91200b1f (docs: support logging session connect attrs to slow query log (#22547)) ``` When the cluster system table is queried, TiDB does not obtain data from all nodes, but pushes down the related calculation to other nodes. The execution plan is as follows: From 144fa3fe7fd5712af330243c4d4523f8c549a6a9 Mon Sep 17 00:00:00 2001 From: yibin87 Date: Fri, 17 Apr 2026 13:02:20 +0800 Subject: [PATCH 3/4] docs: keep release-8.5 slow query schema --- .../information-schema-slow-query.md | 366 +++++++++--------- 1 file changed, 175 insertions(+), 191 deletions(-) diff --git a/information-schema/information-schema-slow-query.md b/information-schema/information-schema-slow-query.md index 54e2d740e3cdb..cb094f2d678a5 100644 --- a/information-schema/information-schema-slow-query.md +++ b/information-schema/information-schema-slow-query.md @@ -35,101 +35,93 @@ DESC SLOW_QUERY; The output is as follows: ```sql -+--------------------------------------------+-----------------+------+------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+--------------------------------------------+-----------------+------+------+---------+-------+ -| Time | timestamp(6) | NO | PRI | NULL | | -| Txn_start_ts | bigint unsigned | YES | | NULL | | -| User | varchar(64) | YES | | NULL | | -| Host | varchar(64) | YES | | NULL | | -| Conn_ID | bigint unsigned | YES | | NULL | | -| Session_alias | varchar(64) | YES | | NULL | | -| Exec_retry_count | bigint unsigned | YES | | NULL | | -| Exec_retry_time | double | YES | | NULL | | -| Query_time | double | YES | | NULL | | -| Parse_time | double | YES | | NULL | | -| Compile_time | double | YES | | NULL | | -| Rewrite_time | double | YES | | NULL | | -| Preproc_subqueries | bigint unsigned | YES | | NULL | | -| Preproc_subqueries_time | double | YES | | NULL | | -| Optimize_time | double | YES | | NULL | | -| Wait_TS | double | YES | | NULL | | -| Prewrite_time | double | YES | | NULL | | -| Wait_prewrite_binlog_time | double | YES | | NULL | | -| Commit_time | double | YES | | NULL | | -| Get_commit_ts_time | double | YES | | NULL | | -| Commit_backoff_time | double | YES | | NULL | | -| Backoff_types | varchar(64) | YES | | NULL | | -| Resolve_lock_time | double | YES | | NULL | | -| Local_latch_wait_time | double | YES | | NULL | | -| Write_keys | bigint | YES | | NULL | | -| Write_size | bigint | YES | | NULL | | -| Prewrite_region | bigint | YES | | NULL | | -| Txn_retry | bigint | YES | | NULL | | -| Cop_time | double | YES | | NULL | | -| Process_time | double | YES | | NULL | | -| Wait_time | double | YES | | NULL | | -| Backoff_time | double | YES | | NULL | | -| LockKeys_time | double | YES | | NULL | | -| Request_count | bigint unsigned | YES | | NULL | | -| Total_keys | bigint unsigned | YES | | NULL | | -| Process_keys | bigint unsigned | YES | | NULL | | -| Rocksdb_delete_skipped_count | bigint unsigned | YES | | NULL | | -| Rocksdb_key_skipped_count | bigint unsigned | YES | | NULL | | -| Rocksdb_block_cache_hit_count | bigint unsigned | YES | | NULL | | -| Rocksdb_block_read_count | bigint unsigned | YES | | NULL | | -| Rocksdb_block_read_byte | bigint unsigned | YES | | NULL | | -| DB | varchar(64) | YES | | NULL | | -| Index_names | varchar(100) | YES | | NULL | | -| Is_internal | tinyint(1) | YES | | NULL | | -| Digest | varchar(64) | YES | | NULL | | -| Stats | varchar(512) | YES | | NULL | | -| Cop_proc_avg | double | YES | | NULL | | -| Cop_proc_p90 | double | YES | | NULL | | -| Cop_proc_max | double | YES | | NULL | | -| Cop_proc_addr | varchar(64) | YES | | NULL | | -| Cop_wait_avg | double | YES | | NULL | | -| Cop_wait_p90 | double | YES | | NULL | | -| Cop_wait_max | double | YES | | NULL | | -| Cop_wait_addr | varchar(64) | YES | | NULL | | -| Mem_max | bigint | YES | | NULL | | -| Disk_max | bigint | YES | | NULL | | -| KV_total | double | YES | | NULL | | -| PD_total | double | YES | | NULL | | -| Backoff_total | double | YES | | NULL | | -| Unpacked_bytes_sent_tikv_total | bigint | YES | | NULL | | -| Unpacked_bytes_received_tikv_total | bigint | YES | | NULL | | -| Unpacked_bytes_sent_tikv_cross_zone | bigint | YES | | NULL | | -| Unpacked_bytes_received_tikv_cross_zone | bigint | YES | | NULL | | -| Unpacked_bytes_sent_tiflash_total | bigint | YES | | NULL | | -| Unpacked_bytes_received_tiflash_total | bigint | YES | | NULL | | -| Unpacked_bytes_sent_tiflash_cross_zone | bigint | YES | | NULL | | -| Unpacked_bytes_received_tiflash_cross_zone | bigint | YES | | NULL | | -| Write_sql_response_total | double | YES | | NULL | | -| Result_rows | bigint | YES | | NULL | | -| Warnings | longtext | YES | | NULL | | -| Backoff_Detail | varchar(4096) | YES | | NULL | | -| Prepared | tinyint(1) | YES | | NULL | | -| Succ | tinyint(1) | YES | | NULL | | -| IsExplicitTxn | tinyint(1) | YES | | NULL | | -| IsWriteCacheTable | tinyint(1) | YES | | NULL | | -| Plan_from_cache | tinyint(1) | YES | | NULL | | -| Plan_from_binding | tinyint(1) | YES | | NULL | | -| Has_more_results | tinyint(1) | YES | | NULL | | -| Resource_group | varchar(64) | YES | | NULL | | -| Request_unit_read | double | YES | | NULL | | -| Request_unit_write | double | YES | | NULL | | -| Time_queued_by_rc | double | YES | | NULL | | -| Tidb_cpu_time | double | YES | | NULL | | -| Tikv_cpu_time | double | YES | | NULL | | -| Plan | longtext | YES | | NULL | | -| Plan_digest | varchar(128) | YES | | NULL | | -| Binary_plan | longtext | YES | | NULL | | -| Prev_stmt | longtext | YES | | NULL | | -| Session_connect_attrs | json | YES | | NULL | | -| Query | longtext | YES | | NULL | | -+--------------------------------------------+-----------------+------+------+---------+-------+ -90 rows in set (0.00 sec) ++-------------------------------+---------------------+------+------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++-------------------------------+---------------------+------+------+---------+-------+ +| Time | timestamp(6) | NO | PRI | NULL | | +| Txn_start_ts | bigint(20) unsigned | YES | | NULL | | +| User | varchar(64) | YES | | NULL | | +| Host | varchar(64) | YES | | NULL | | +| Conn_ID | bigint(20) unsigned | YES | | NULL | | +| Session_alias | varchar(64) | YES | | NULL | | +| Exec_retry_count | bigint(20) unsigned | YES | | NULL | | +| Exec_retry_time | double | YES | | NULL | | +| Query_time | double | YES | | NULL | | +| Parse_time | double | YES | | NULL | | +| Compile_time | double | YES | | NULL | | +| Rewrite_time | double | YES | | NULL | | +| Preproc_subqueries | bigint(20) unsigned | YES | | NULL | | +| Preproc_subqueries_time | double | YES | | NULL | | +| Optimize_time | double | YES | | NULL | | +| Wait_TS | double | YES | | NULL | | +| Prewrite_time | double | YES | | NULL | | +| Wait_prewrite_binlog_time | double | YES | | NULL | | +| Commit_time | double | YES | | NULL | | +| Get_commit_ts_time | double | YES | | NULL | | +| Commit_backoff_time | double | YES | | NULL | | +| Backoff_types | varchar(64) | YES | | NULL | | +| Resolve_lock_time | double | YES | | NULL | | +| Local_latch_wait_time | double | YES | | NULL | | +| Write_keys | bigint(22) | YES | | NULL | | +| Write_size | bigint(22) | YES | | NULL | | +| Prewrite_region | bigint(22) | YES | | NULL | | +| Txn_retry | bigint(22) | YES | | NULL | | +| Cop_time | double | YES | | NULL | | +| Process_time | double | YES | | NULL | | +| Wait_time | double | YES | | NULL | | +| Backoff_time | double | YES | | NULL | | +| LockKeys_time | double | YES | | NULL | | +| Request_count | bigint(20) unsigned | YES | | NULL | | +| Total_keys | bigint(20) unsigned | YES | | NULL | | +| Process_keys | bigint(20) unsigned | YES | | NULL | | +| Rocksdb_delete_skipped_count | bigint(20) unsigned | YES | | NULL | | +| Rocksdb_key_skipped_count | bigint(20) unsigned | YES | | NULL | | +| Rocksdb_block_cache_hit_count | bigint(20) unsigned | YES | | NULL | | +| Rocksdb_block_read_count | bigint(20) unsigned | YES | | NULL | | +| Rocksdb_block_read_byte | bigint(20) unsigned | YES | | NULL | | +| DB | varchar(64) | YES | | NULL | | +| Index_names | varchar(100) | YES | | NULL | | +| Is_internal | tinyint(1) | YES | | NULL | | +| Digest | varchar(64) | YES | | NULL | | +| Stats | varchar(512) | YES | | NULL | | +| Cop_proc_avg | double | YES | | NULL | | +| Cop_proc_p90 | double | YES | | NULL | | +| Cop_proc_max | double | YES | | NULL | | +| Cop_proc_addr | varchar(64) | YES | | NULL | | +| Cop_wait_avg | double | YES | | NULL | | +| Cop_wait_p90 | double | YES | | NULL | | +| Cop_wait_max | double | YES | | NULL | | +| Cop_wait_addr | varchar(64) | YES | | NULL | | +| Mem_max | bigint(20) | YES | | NULL | | +| Disk_max | bigint(20) | YES | | NULL | | +| KV_total | double | YES | | NULL | | +| PD_total | double | YES | | NULL | | +| Backoff_total | double | YES | | NULL | | +| Write_sql_response_total | double | YES | | NULL | | +| Result_rows | bigint(22) | YES | | NULL | | +| Warnings | longtext | YES | | NULL | | +| Backoff_Detail | varchar(4096) | YES | | NULL | | +| Prepared | tinyint(1) | YES | | NULL | | +| Succ | tinyint(1) | YES | | NULL | | +| IsExplicitTxn | tinyint(1) | YES | | NULL | | +| IsWriteCacheTable | tinyint(1) | YES | | NULL | | +| Plan_from_cache | tinyint(1) | YES | | NULL | | +| Plan_from_binding | tinyint(1) | YES | | NULL | | +| Has_more_results | tinyint(1) | YES | | NULL | | +| Resource_group | varchar(64) | YES | | NULL | | +| Request_unit_read | double | YES | | NULL | | +| Request_unit_write | double | YES | | NULL | | +| Time_queued_by_rc | double | YES | | NULL | | +| Tidb_cpu_time | double | YES | | NULL | | +| Tikv_cpu_time | double | YES | | NULL | | +| Plan | longtext | YES | | NULL | | +| Plan_digest | varchar(128) | YES | | NULL | | +| Binary_plan | longtext | YES | | NULL | | +| Prev_stmt | longtext | YES | | NULL | | +| Session_connect_attrs | json | YES | | NULL | | +| Query | longtext | YES | | NULL | | ++-------------------------------+---------------------+------+------+---------+-------+ +82 rows in set (0.00 sec) ``` The maximum statement length of the `Query` column is limited by the [`tidb_stmt_summary_max_sql_length`](/system-variables.md#tidb_stmt_summary_max_sql_length-new-in-v40) system variable. @@ -157,102 +149,94 @@ DESC CLUSTER_SLOW_QUERY; The output is as follows: ```sql -+--------------------------------------------+-----------------+------+------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+--------------------------------------------+-----------------+------+------+---------+-------+ -| INSTANCE | varchar(64) | YES | | NULL | | -| Time | timestamp(6) | NO | PRI | NULL | | -| Txn_start_ts | bigint unsigned | YES | | NULL | | -| User | varchar(64) | YES | | NULL | | -| Host | varchar(64) | YES | | NULL | | -| Conn_ID | bigint unsigned | YES | | NULL | | -| Session_alias | varchar(64) | YES | | NULL | | -| Exec_retry_count | bigint unsigned | YES | | NULL | | -| Exec_retry_time | double | YES | | NULL | | -| Query_time | double | YES | | NULL | | -| Parse_time | double | YES | | NULL | | -| Compile_time | double | YES | | NULL | | -| Rewrite_time | double | YES | | NULL | | -| Preproc_subqueries | bigint unsigned | YES | | NULL | | -| Preproc_subqueries_time | double | YES | | NULL | | -| Optimize_time | double | YES | | NULL | | -| Wait_TS | double | YES | | NULL | | -| Prewrite_time | double | YES | | NULL | | -| Wait_prewrite_binlog_time | double | YES | | NULL | | -| Commit_time | double | YES | | NULL | | -| Get_commit_ts_time | double | YES | | NULL | | -| Commit_backoff_time | double | YES | | NULL | | -| Backoff_types | varchar(64) | YES | | NULL | | -| Resolve_lock_time | double | YES | | NULL | | -| Local_latch_wait_time | double | YES | | NULL | | -| Write_keys | bigint | YES | | NULL | | -| Write_size | bigint | YES | | NULL | | -| Prewrite_region | bigint | YES | | NULL | | -| Txn_retry | bigint | YES | | NULL | | -| Cop_time | double | YES | | NULL | | -| Process_time | double | YES | | NULL | | -| Wait_time | double | YES | | NULL | | -| Backoff_time | double | YES | | NULL | | -| LockKeys_time | double | YES | | NULL | | -| Request_count | bigint unsigned | YES | | NULL | | -| Total_keys | bigint unsigned | YES | | NULL | | -| Process_keys | bigint unsigned | YES | | NULL | | -| Rocksdb_delete_skipped_count | bigint unsigned | YES | | NULL | | -| Rocksdb_key_skipped_count | bigint unsigned | YES | | NULL | | -| Rocksdb_block_cache_hit_count | bigint unsigned | YES | | NULL | | -| Rocksdb_block_read_count | bigint unsigned | YES | | NULL | | -| Rocksdb_block_read_byte | bigint unsigned | YES | | NULL | | -| DB | varchar(64) | YES | | NULL | | -| Index_names | varchar(100) | YES | | NULL | | -| Is_internal | tinyint(1) | YES | | NULL | | -| Digest | varchar(64) | YES | | NULL | | -| Stats | varchar(512) | YES | | NULL | | -| Cop_proc_avg | double | YES | | NULL | | -| Cop_proc_p90 | double | YES | | NULL | | -| Cop_proc_max | double | YES | | NULL | | -| Cop_proc_addr | varchar(64) | YES | | NULL | | -| Cop_wait_avg | double | YES | | NULL | | -| Cop_wait_p90 | double | YES | | NULL | | -| Cop_wait_max | double | YES | | NULL | | -| Cop_wait_addr | varchar(64) | YES | | NULL | | -| Mem_max | bigint | YES | | NULL | | -| Disk_max | bigint | YES | | NULL | | -| KV_total | double | YES | | NULL | | -| PD_total | double | YES | | NULL | | -| Backoff_total | double | YES | | NULL | | -| Unpacked_bytes_sent_tikv_total | bigint | YES | | NULL | | -| Unpacked_bytes_received_tikv_total | bigint | YES | | NULL | | -| Unpacked_bytes_sent_tikv_cross_zone | bigint | YES | | NULL | | -| Unpacked_bytes_received_tikv_cross_zone | bigint | YES | | NULL | | -| Unpacked_bytes_sent_tiflash_total | bigint | YES | | NULL | | -| Unpacked_bytes_received_tiflash_total | bigint | YES | | NULL | | -| Unpacked_bytes_sent_tiflash_cross_zone | bigint | YES | | NULL | | -| Unpacked_bytes_received_tiflash_cross_zone | bigint | YES | | NULL | | -| Write_sql_response_total | double | YES | | NULL | | -| Result_rows | bigint | YES | | NULL | | -| Warnings | longtext | YES | | NULL | | -| Backoff_Detail | varchar(4096) | YES | | NULL | | -| Prepared | tinyint(1) | YES | | NULL | | -| Succ | tinyint(1) | YES | | NULL | | -| IsExplicitTxn | tinyint(1) | YES | | NULL | | -| IsWriteCacheTable | tinyint(1) | YES | | NULL | | -| Plan_from_cache | tinyint(1) | YES | | NULL | | -| Plan_from_binding | tinyint(1) | YES | | NULL | | -| Has_more_results | tinyint(1) | YES | | NULL | | -| Resource_group | varchar(64) | YES | | NULL | | -| Request_unit_read | double | YES | | NULL | | -| Request_unit_write | double | YES | | NULL | | -| Time_queued_by_rc | double | YES | | NULL | | -| Tidb_cpu_time | double | YES | | NULL | | -| Tikv_cpu_time | double | YES | | NULL | | -| Plan | longtext | YES | | NULL | | -| Plan_digest | varchar(128) | YES | | NULL | | -| Binary_plan | longtext | YES | | NULL | | -| Prev_stmt | longtext | YES | | NULL | | -| Session_connect_attrs | json | YES | | NULL | | -| Query | longtext | YES | | NULL | | -+--------------------------------------------+-----------------+------+------+---------+-------+ -91 rows in set (0.00 sec) ++-------------------------------+---------------------+------+------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++-------------------------------+---------------------+------+------+---------+-------+ +| INSTANCE | varchar(64) | YES | | NULL | | +| Time | timestamp(6) | NO | PRI | NULL | | +| Txn_start_ts | bigint(20) unsigned | YES | | NULL | | +| User | varchar(64) | YES | | NULL | | +| Host | varchar(64) | YES | | NULL | | +| Conn_ID | bigint(20) unsigned | YES | | NULL | | +| Session_alias | varchar(64) | YES | | NULL | | +| Exec_retry_count | bigint(20) unsigned | YES | | NULL | | +| Exec_retry_time | double | YES | | NULL | | +| Query_time | double | YES | | NULL | | +| Parse_time | double | YES | | NULL | | +| Compile_time | double | YES | | NULL | | +| Rewrite_time | double | YES | | NULL | | +| Preproc_subqueries | bigint(20) unsigned | YES | | NULL | | +| Preproc_subqueries_time | double | YES | | NULL | | +| Optimize_time | double | YES | | NULL | | +| Wait_TS | double | YES | | NULL | | +| Prewrite_time | double | YES | | NULL | | +| Wait_prewrite_binlog_time | double | YES | | NULL | | +| Commit_time | double | YES | | NULL | | +| Get_commit_ts_time | double | YES | | NULL | | +| Commit_backoff_time | double | YES | | NULL | | +| Backoff_types | varchar(64) | YES | | NULL | | +| Resolve_lock_time | double | YES | | NULL | | +| Local_latch_wait_time | double | YES | | NULL | | +| Write_keys | bigint(22) | YES | | NULL | | +| Write_size | bigint(22) | YES | | NULL | | +| Prewrite_region | bigint(22) | YES | | NULL | | +| Txn_retry | bigint(22) | YES | | NULL | | +| Cop_time | double | YES | | NULL | | +| Process_time | double | YES | | NULL | | +| Wait_time | double | YES | | NULL | | +| Backoff_time | double | YES | | NULL | | +| LockKeys_time | double | YES | | NULL | | +| Request_count | bigint(20) unsigned | YES | | NULL | | +| Total_keys | bigint(20) unsigned | YES | | NULL | | +| Process_keys | bigint(20) unsigned | YES | | NULL | | +| Rocksdb_delete_skipped_count | bigint(20) unsigned | YES | | NULL | | +| Rocksdb_key_skipped_count | bigint(20) unsigned | YES | | NULL | | +| Rocksdb_block_cache_hit_count | bigint(20) unsigned | YES | | NULL | | +| Rocksdb_block_read_count | bigint(20) unsigned | YES | | NULL | | +| Rocksdb_block_read_byte | bigint(20) unsigned | YES | | NULL | | +| DB | varchar(64) | YES | | NULL | | +| Index_names | varchar(100) | YES | | NULL | | +| Is_internal | tinyint(1) | YES | | NULL | | +| Digest | varchar(64) | YES | | NULL | | +| Stats | varchar(512) | YES | | NULL | | +| Cop_proc_avg | double | YES | | NULL | | +| Cop_proc_p90 | double | YES | | NULL | | +| Cop_proc_max | double | YES | | NULL | | +| Cop_proc_addr | varchar(64) | YES | | NULL | | +| Cop_wait_avg | double | YES | | NULL | | +| Cop_wait_p90 | double | YES | | NULL | | +| Cop_wait_max | double | YES | | NULL | | +| Cop_wait_addr | varchar(64) | YES | | NULL | | +| Mem_max | bigint(20) | YES | | NULL | | +| Disk_max | bigint(20) | YES | | NULL | | +| KV_total | double | YES | | NULL | | +| PD_total | double | YES | | NULL | | +| Backoff_total | double | YES | | NULL | | +| Write_sql_response_total | double | YES | | NULL | | +| Result_rows | bigint(22) | YES | | NULL | | +| Warnings | longtext | YES | | NULL | | +| Backoff_Detail | varchar(4096) | YES | | NULL | | +| Prepared | tinyint(1) | YES | | NULL | | +| Succ | tinyint(1) | YES | | NULL | | +| IsExplicitTxn | tinyint(1) | YES | | NULL | | +| IsWriteCacheTable | tinyint(1) | YES | | NULL | | +| Plan_from_cache | tinyint(1) | YES | | NULL | | +| Plan_from_binding | tinyint(1) | YES | | NULL | | +| Has_more_results | tinyint(1) | YES | | NULL | | +| Resource_group | varchar(64) | YES | | NULL | | +| Request_unit_read | double | YES | | NULL | | +| Request_unit_write | double | YES | | NULL | | +| Time_queued_by_rc | double | YES | | NULL | | +| Tidb_cpu_time | double | YES | | NULL | | +| Tikv_cpu_time | double | YES | | NULL | | +| Plan | longtext | YES | | NULL | | +| Plan_digest | varchar(128) | YES | | NULL | | +| Binary_plan | longtext | YES | | NULL | | +| Prev_stmt | longtext | YES | | NULL | | +| Session_connect_attrs | json | YES | | NULL | | +| Query | longtext | YES | | NULL | | ++-------------------------------+---------------------+------+------+---------+-------+ +83 rows in set (0.00 sec) ``` When the cluster system table is queried, TiDB does not obtain data from all nodes, but pushes down the related calculation to other nodes. The execution plan is as follows: From 787ac0c938f6d668592acfdc6a2f5520fbdf3ea7 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Mon, 20 Apr 2026 09:29:54 +0800 Subject: [PATCH 4/4] Apply suggestions from code review --- information-schema/information-schema-slow-query.md | 2 +- performance-schema/performance-schema-session-connect-attrs.md | 2 +- system-variable-reference.md | 2 +- system-variables.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/information-schema/information-schema-slow-query.md b/information-schema/information-schema-slow-query.md index cb094f2d678a5..6661882effb5d 100644 --- a/information-schema/information-schema-slow-query.md +++ b/information-schema/information-schema-slow-query.md @@ -126,7 +126,7 @@ The output is as follows: The maximum statement length of the `Query` column is limited by the [`tidb_stmt_summary_max_sql_length`](/system-variables.md#tidb_stmt_summary_max_sql_length-new-in-v40) system variable. -The `Session_connect_attrs` column stores session connection attributes in JSON format parsed from the slow log. TiDB controls the maximum payload size written to this field using [`performance_schema_session_connect_attrs_size`](/system-variables.md#performance_schema_session_connect_attrs_size-new-in-v900). +The `Session_connect_attrs` column stores session connection attributes in JSON format parsed from the slow log. TiDB controls the maximum payload size written to this field using [`performance_schema_session_connect_attrs_size`](/system-variables.md#performance_schema_session_connect_attrs_size-new-in-v857). ## CLUSTER_SLOW_QUERY table diff --git a/performance-schema/performance-schema-session-connect-attrs.md b/performance-schema/performance-schema-session-connect-attrs.md index 02a793bfb953d..b5cd622f1e2bc 100644 --- a/performance-schema/performance-schema-session-connect-attrs.md +++ b/performance-schema/performance-schema-session-connect-attrs.md @@ -69,7 +69,7 @@ Fields in the `SESSION_CONNECT_ATTRS` table are described as follows: ## Size limit and truncation -TiDB uses the [`performance_schema_session_connect_attrs_size`](/system-variables.md#performance_schema_session_connect_attrs_size-new-in-v900) global system variable to control the maximum total size of connection attributes per session. +TiDB uses the [`performance_schema_session_connect_attrs_size`](/system-variables.md#performance_schema_session_connect_attrs_size-new-in-v857) global system variable to control the maximum total size of connection attributes per session. - Default value: `4096` bytes - Range: `[-1, 65536]` diff --git a/system-variable-reference.md b/system-variable-reference.md index f6e845fb3d11c..3418a91b37982 100644 --- a/system-variable-reference.md +++ b/system-variable-reference.md @@ -599,7 +599,7 @@ Referenced in: Referenced in: - [`SESSION_CONNECT_ATTRS`](/performance-schema/performance-schema-session-connect-attrs.md) -- [System Variables](/system-variables.md#performance_schema_session_connect_attrs_size-new-in-v900) +- [System Variables](/system-variables.md#performance_schema_session_connect_attrs_size-new-in-v857) ### plugin_dir diff --git a/system-variables.md b/system-variables.md index bfdbfbaf056dd..954780d6fdc08 100644 --- a/system-variables.md +++ b/system-variables.md @@ -794,7 +794,7 @@ mysql> SHOW GLOBAL VARIABLES LIKE 'max_prepared_stmt_count'; * In a cluster with a large number of Regions, the PD leader experiences high CPU pressure due to the increased overhead of handling heartbeats and scheduling tasks. * In a TiDB cluster with many TiDB instances, the PD leader experiences high CPU pressure due to a high concurrency of requests for Region information. -### performance_schema_session_connect_attrs_size New in v9.0.0 +### performance_schema_session_connect_attrs_size New in v8.5.7 - Scope: GLOBAL - Persists to cluster: Yes