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
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.
135
136
137
+
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).
138
+
136
139
## CLUSTER_SLOW_QUERY table
137
140
138
141
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.
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:
Copy file name to clipboardExpand all lines: performance-schema/performance-schema-session-connect-attrs.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,3 +66,18 @@ Fields in the `SESSION_CONNECT_ATTRS` table are described as follows:
66
66
*`ATTR_NAME`: Attribute name.
67
67
*`ATTR_VALUE`: Attribute value.
68
68
*`ORDINAL_POSITION`: Ordinal position of the name/value pair.
69
+
70
+
## Size limit and truncation
71
+
72
+
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.
73
+
74
+
- Default value: `4096` bytes
75
+
- Range: `[-1, 65536]`
76
+
-`-1` means no configured limit, and TiDB treats it as up to `65536` bytes.
77
+
-`0` means that TiDB does not retain client-provided session connection attributes, which effectively disables recording session attributes.
78
+
79
+
When the total size exceeds this limit, TiDB truncates excess attributes and adds `_truncated` to indicate the number of truncated bytes.
80
+
81
+
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`.
82
+
83
+
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.
Copy file name to clipboardExpand all lines: system-variables.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -803,6 +803,26 @@ mysql> SHOW GLOBAL VARIABLES LIKE 'max_prepared_stmt_count';
803
803
* 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.
804
804
* 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.
805
805
806
+
### performance_schema_session_connect_attrs_size <spanclass="version-mark">New in v9.0.0</span>
807
+
808
+
- Scope: GLOBAL
809
+
- Persists to cluster: Yes
810
+
- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No
811
+
- Type: Integer
812
+
- Default value: `4096`
813
+
- Range: `[-1, 65536]`
814
+
- Unit: Bytes
815
+
- Controls the maximum total size of connection attributes for each session.
816
+
- If the total size of connection attributes exceeds this value, TiDB truncates excess attributes and adds `_truncated` to indicate the number of truncated bytes.
817
+
- 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`.
818
+
- You can control the size of `Session_connect_attrs` recorded in the slow log by adjusting this variable.
819
+
- If the value is set to `-1`, this means the limit is not configured and TiDB treats it as up to `65536` bytes.
820
+
- If the value is set to `0`, TiDB does not retain client-provided session connection attributes, which effectively disables recording session attributes.
821
+
822
+
> **Note:**
823
+
>
824
+
> TiDB enforces a hard limit of 1 MiB for handshake connection attributes. If this hard limit is exceeded, the connection is rejected.
0 commit comments