diff --git a/identify-expensive-queries.md b/identify-expensive-queries.md index d9b9e762ee29..6dc97c6248dc 100644 --- a/identify-expensive-queries.md +++ b/identify-expensive-queries.md @@ -12,7 +12,7 @@ TiDB 会将执行时间超过 [`tidb_expensive_query_time_threshold`](/system-va ## Expensive query 日志示例 ```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=] ``` ## 字段含义说明 @@ -24,6 +24,7 @@ TiDB 会将执行时间超过 [`tidb_expensive_query_time_threshold`](/system-va * `table_ids`:语句涉及到的表的 ID。 * `txn_start_ts`:事务的开始时间戳,也是事务的唯一 ID,可以用这个值在 TiDB 日志中查找事务相关的其他日志。 * `sql`:SQL 语句。 +* `session_alias`:当前连接的别名。 和内存使用相关的字段: diff --git a/information-schema/information-schema-processlist.md b/information-schema/information-schema-processlist.md index ab8493cdf741..1d04e3dbf287 100644 --- a/information-schema/information-schema-processlist.md +++ b/information-schema/information-schema-processlist.md @@ -12,8 +12,9 @@ summary: 了解 information_schema 表 `PROCESSLIST`。 * `DIGEST` 列:显示 SQL 语句的 digest。 * `MEM` 列:显示正在处理的请求已使用的内存,单位是 byte。 * `DISK` 列:显示磁盘空间使用情况,单位是 byte。 -* `TxnStart`列:显示事务的开始时间。 -* `RESOURCE_GROUP`列:显示对应的资源组名称。 +* `TxnStart` 列:显示事务的开始时间。 +* `RESOURCE_GROUP` 列:显示对应的资源组名称。 +* `SESSION_ALIAS` 列:显示当前连接的别名。 ```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) ``` @@ -76,8 +79,9 @@ SELECT * FROM processlist\G * `DIGEST` 列:SQL 语句的 digest。 * `MEM` 列:正在处理的请求已使用的内存,单位是 byte。 * `DISK` 列:磁盘空间使用情况,单位是 byte。 -* `TxnStart`列:显示事务的开始时间。 -* `RESOURCE_GROUP`列:显示对应的资源组名称。 +* `TxnStart` 列:显示事务的开始时间。 +* `RESOURCE_GROUP` 列:显示对应的资源组名称。 +* `SESSION_ALIAS` 列:显示当前连接的别名。 ## CLUSTER_PROCESSLIST @@ -90,14 +94,14 @@ SELECT * FROM information_schema.cluster_processlist; ``` ```sql -+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+ -| INSTANCE | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | MEM | TxnStart | RESOURCE_GROUP | -+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+ - -| 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 | -+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+ ++-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+---------------+ +| 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 | | ++-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+---------------+ ``` diff --git a/releases/release-8.2.0.md b/releases/release-8.2.0.md index f3bc50786d32..74bf443c3c32 100644 --- a/releases/release-8.2.0.md +++ b/releases/release-8.2.0.md @@ -184,6 +184,10 @@ TiDB 版本:8.2.0 | TiKV | [`server.grpc-compression-type`](/tikv-configuration-file.md#grpc-compression-type) | 修改 | 该配置项现在也会影响 TiKV 向 TiDB 发送的响应消息的压缩算法。开启压缩可能消耗更多 CPU 资源。 | | TiFlash | [`security.redact_info_log`](/tiflash/tiflash-configuration.md#配置文件-tiflashtoml) | 修改 | 可选值新增 `marker` 选项。当配置项的值设置为 `marker` 时,日志中的用户数据会被标记符号 `‹ ›` 包裹。 | +### 系统表 + +* 在系统表 [`INFORMATION_SCHEMA.PROCESSLIST`](/information-schema/information-schema-processlist.md) 和 [`INFORMATION_SCHEMA.CLUSTER_PROCESSLIST`](/information-schema/information-schema-processlist.md#cluster_processlist) 中新增 `SESSION_ALIAS` 字段,用于显示当前连接的别名。[#46889](https://github.com/pingcap/tidb/issues/46889) @[lcwangchao](https://github.com/lcwangchao) + ### 编译器版本 * 为了提升 TiFlash 的开发体验,编译和构建 TiDB 所需的 LLVM 的最低版本从 13.0 升级到了 17.0。如果你是 TiDB 开发者,为了保证顺利编译,请对应升级你的 LLVM 编译器版本。[#7193](https://github.com/pingcap/tiflash/issues/7193) @[Lloyd-Pottiger](https://github.com/Lloyd-Pottiger)