Skip to content
Open
Show file tree
Hide file tree
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
185 changes: 185 additions & 0 deletions information-schema/information-schema-slow-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ DESC SLOW_QUERY;
The output is as follows:

```sql
<<<<<<< HEAD
+--------------------------------------------+-----------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------------------------+-----------------+------+------+---------+-------+
Expand Down Expand Up @@ -130,11 +131,104 @@ The output is as follows:
| 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)
>>>>>>> 68bb5e64f0 (v8.5.7: support logging session connect attrs to slow query log (#22547) (#22775))
```

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.

<<<<<<< HEAD
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).
>>>>>>> 68bb5e64f0 (v8.5.7: support logging session connect attrs to slow query log (#22547) (#22775))
Comment on lines +227 to +231

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There is an unresolved merge conflict here. Please resolve it by keeping the v8.5.7 version and removing the v9.0.0 version and conflict markers:

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.


## CLUSTER_SLOW_QUERY table

Expand All @@ -157,6 +251,7 @@ DESC CLUSTER_SLOW_QUERY;
The output is as follows:

```sql
<<<<<<< HEAD
+--------------------------------------------+-----------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------------------------+-----------------+------+------+---------+-------+
Expand Down Expand Up @@ -253,6 +348,96 @@ The output is as follows:
| 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)
>>>>>>> 68bb5e64f0 (v8.5.7: support logging session connect attrs to slow query log (#22547) (#22775))
```

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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ Fields in the `SESSION_CONNECT_ATTRS` table are described as follows:

## Size limit and truncation

<<<<<<< HEAD
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.
>>>>>>> 68bb5e64f0 (v8.5.7: support logging session connect attrs to slow query log (#22547) (#22775))
Comment on lines +72 to +76

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There is an unresolved merge conflict here. Please resolve it by keeping the v8.5.7 version and removing the v9.0.0 version and conflict markers:

TiDB uses the performance_schema_session_connect_attrs_size global system variable to control the maximum total size of connection attributes per session.


- Default value: `4096` bytes
- Range: `[-1, 65536]`
Expand Down
4 changes: 4 additions & 0 deletions system-variable-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,11 @@ Referenced in:
Referenced in:

- [`SESSION_CONNECT_ATTRS`](/performance-schema/performance-schema-session-connect-attrs.md)
<<<<<<< HEAD
- [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)
>>>>>>> 68bb5e64f0 (v8.5.7: support logging session connect attrs to slow query log (#22547) (#22775))
Comment on lines +608 to +612

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There is an unresolved merge conflict here. Please resolve it by keeping the v8.5.7 version and removing the v9.0.0 version and conflict markers:


### plugin_dir

Expand Down
4 changes: 4 additions & 0 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,11 @@ 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.

<<<<<<< HEAD
### performance_schema_session_connect_attrs_size <span class="version-mark">New in v9.0.0</span>
=======
### performance_schema_session_connect_attrs_size <span class="version-mark">New in v8.5.7</span>
>>>>>>> 68bb5e64f0 (v8.5.7: support logging session connect attrs to slow query log (#22547) (#22775))
Comment on lines +814 to +818

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There is an unresolved merge conflict here. Please resolve it by keeping the v8.5.7 version and removing the v9.0.0 version and conflict markers.

Suggested change
<<<<<<< HEAD
### performance_schema_session_connect_attrs_size <span class="version-mark">New in v9.0.0</span>
=======
### performance_schema_session_connect_attrs_size <span class="version-mark">New in v8.5.7</span>
>>>>>>> 68bb5e64f0 (v8.5.7: support logging session connect attrs to slow query log (#22547) (#22775))
### performance_schema_session_connect_attrs_size <span class="version-mark">New in v8.5.7</span>


- Scope: GLOBAL
- Persists to cluster: Yes
Expand Down