diff --git a/identify-expensive-queries.md b/identify-expensive-queries.md index c1b7919be26c..50786a7f54a0 100644 --- a/identify-expensive-queries.md +++ b/identify-expensive-queries.md @@ -14,7 +14,7 @@ TiDB allows you to identify expensive queries during SQL execution, so you can d ## Expensive query log example ```sql -[2020/02/05 15:32:25.096 +08:00] [WARN] [expensivequery.go:167] [expensive_query] [cost_time=60.008338935s] [wait_time=0s] [request_count=1] [total_keys=70] [process_keys=65] [num_cop_tasks=1] [process_avg_time=0s] [process_p90_time=0s] [process_max_time=0s] [process_max_addr=10.0.1.9:20160] [wait_avg_time=0.002s] [wait_p90_time=0.002s] [wait_max_time=0.002s] [wait_max_addr=10.0.1.9:20160] [stats=t:pseudo] [conn_id=60026] [user=root] [database=test] [table_ids="[122]"] [txn_start_ts=414420273735139329] [mem_max="1035 Bytes (1.0107421875 KB)"] [sql="insert into t select sleep(1) from t"] +[2024/07/11 15:32:25.096 +08:00] [WARN] [expensivequery.go:167] [expensive_query] [cost_time=60.008338935s] [wait_time=0s] [request_count=1] [total_keys=70] [process_keys=65] [num_cop_tasks=1] [process_avg_time=0s] [process_p90_time=0s] [process_max_time=0s] [process_max_addr=10.0.1.9:20160] [wait_avg_time=0.002s] [wait_p90_time=0.002s] [wait_max_time=0.002s] [wait_max_addr=10.0.1.9:20160] [stats=t:pseudo] [conn_id=60026] [user=root] [database=test] [table_ids="[122]"] [txn_start_ts=414420273735139329] [mem_max="1035 Bytes (1.0107421875 KB)"] [sql="insert into t select sleep(1) from t"] [session_alias=] ``` ## Fields description @@ -26,6 +26,7 @@ Basic fields: * `table_ids`: The IDs of the tables involved in a statement. * `txn_start_ts`: The start timestamp and the unique ID of a transaction. You can use this value to search for the transaction-related logs. * `sql`: The sql statement. +* `session_alias`: The alias of the current session. Memory usage related fields: diff --git a/information-schema/information-schema-processlist.md b/information-schema/information-schema-processlist.md index 7d228fe385e2..9b410ddfae3d 100644 --- a/information-schema/information-schema-processlist.md +++ b/information-schema/information-schema-processlist.md @@ -14,6 +14,7 @@ The `PROCESSLIST` table has additional columns not present in `SHOW PROCESSLIST` * A `DISK` column to show the disk usage in bytes. * A `TxnStart` column to show the start time of the transaction. * A `RESOURCE_GROUP` column to show the resource group name. +* A `SESSION_ALIAS` column to show the alias of the current session. ```sql USE information_schema; @@ -37,6 +38,7 @@ DESC processlist; | DISK | bigint(21) unsigned | YES | | NULL | | | TxnStart | varchar(64) | NO | | | | | RESOURCE_GROUP | varchar(32) | NO | | | | +| SESSION_ALIAS | varchar(64) | NO | | | | +---------------------+---------------------+------+------+---------+-------+ 13 rows in set (0.00 sec) ``` @@ -60,6 +62,7 @@ SELECT * FROM processlist\G DISK: 0 TxnStart: RESOURCE_GROUP: rg1 + SESSION_ALIAS: 1 row in set (0.00 sec) ``` @@ -78,6 +81,7 @@ Fields in the `PROCESSLIST` table are described as follows: * DISK: The disk usage in bytes. * TxnStart: The start time of the transaction. * RESOURCE_GROUP: The resource group name. +* SESSION_ALIAS: The alias of the current session. ## CLUSTER_PROCESSLIST @@ -88,14 +92,14 @@ SELECT * FROM information_schema.cluster_processlist; ``` ```sql -+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+ -| INSTANCE | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | MEM | TxnStart | RESOURCE_GROUP | -+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+ ++-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+---------------+ +| INSTANCE | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | MEM | TxnStart | RESOURCE_GROUP | SESSION_ALIAS | ++-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+---------------+ -| 10.0.1.22:10080 | 150 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077223) | default | -| 10.0.1.22:10080 | 138 | root | 10.0.1.1 | test | Query | 0 | autocommit | SELECT * FROM information_schema.cluster_processlist | 0 | 05-28 03:54:21.230(416976223923077220) | rg1 | -| 10.0.1.22:10080 | 151 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077224) | rg2 | -| 10.0.1.21:10080 | 15 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077222) | default | -| 10.0.1.21:10080 | 14 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077225) | default | -+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+ +| 10.0.1.22:10080 | 150 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077223) | default | | +| 10.0.1.22:10080 | 138 | root | 10.0.1.1 | test | Query | 0 | autocommit | SELECT * FROM information_schema.cluster_processlist | 0 | 05-28 03:54:21.230(416976223923077220) | rg1 | | +| 10.0.1.22:10080 | 151 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077224) | rg2 | | +| 10.0.1.21:10080 | 15 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077222) | default | | +| 10.0.1.21:10080 | 14 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077225) | default | | ++-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+---------------+ ``` diff --git a/releases/release-8.2.0.md b/releases/release-8.2.0.md index 049c018427b9..d6a46e076168 100644 --- a/releases/release-8.2.0.md +++ b/releases/release-8.2.0.md @@ -186,6 +186,10 @@ Quick access: [Quick start](https://docs.pingcap.com/tidb/v8.2/quick-start-with- | TiKV | [`server.grpc-compression-type`](/tikv-configuration-file.md#grpc-compression-type) | Modified | This configuration item now also controls the compression algorithm of response messages sent from TiKV to TiDB. Enabling compression might consume more CPU resources. | | TiFlash | [`security.redact_info_log`](/tiflash/tiflash-configuration.md#configure-the-tiflashtoml-file) | Modified | Introduces a new value option `marker`. When you set the value to `marker`, all user data in the log is wrapped in `‹ ›`. | +### System tables + +* The [`INFORMATION_SCHEMA.PROCESSLIST`](/information-schema/information-schema-processlist.md) and [`INFORMATION_SCHEMA.CLUSTER_PROCESSLIST`](/information-schema/information-schema-processlist.md#cluster_processlist) system tables add the `SESSION_ALIAS` field to show the alias of the current session. [#46889](https://github.com/pingcap/tidb/issues/46889) @[lcwangchao](https://github.com/lcwangchao) + ### Compiler versions * To improve the TiFlash development experience, the minimum version of LLVM required to compile and build TiDB has been upgraded from 13.0 to 17.0. If you are a TiDB developer, you need to upgrade the version of your LLVM compiler to ensure a smooth build. [#7193](https://github.com/pingcap/tiflash/issues/7193) @[Lloyd-Pottiger](https://github.com/Lloyd-Pottiger)