# STATEMENT_HISTORY
STATEMENT_HISTORY获得当前节点的执行语句的信息。查询系统表必须具有sysadmin权限。只可在系统库中查询到结果，用户库中无法查询。
对于此系统表查询有如下约束：
- 必须在postgres库内查询，其它库中不存数据。
- 此系统表受track_stmt_stat_level控制，默认为"OFF,L0"，第一部分控制Full SQL，第二部分控制Slow SQL，具体字段记录级别见下表。考虑性能影响，更改该参数的值时建议通过set方式设置，使该参数仅对当前会话生效。
- 当track_stmt_stat_level中Full SQL和Slow SQL不全为OFF时，对于超过log_min_duration_statement阈值的SQL，is_slow_sql字段会记录为true，表明这是一个超过阈值的SQL，其他字段以track_stmt_stat_level中的级别为记录标准。
 
 表1STATEMENT_HISTORY字段 
| 名称                      | 类型                      | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | 最低记录级别                                                                |
|:---|:---|:---|:---|
| db_name                | name                      | 数据库名称。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | L0                                                                     |
| schema_name             | name                     | 模式名称。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | L0                                                                    |
| origin_node            | integer                   | 节点名称，当前版本中该值为0。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | L0                                                                   |
| user_name                | name                      | 用户名。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | L0                                                                    |
| application_name        | text                   | 用户发起的请求的应用程序名称。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | L0                                                                    |
| client_addr            | text                    | 用户发起的请求的客户端地址。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | L0                                                                    |
| client_port            | integer                  | 用户发起的请求的客户端端口。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | L0                                                                  |
| unique_query_id         | bigint                 | 归一化SQL ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | L0                                                                    |
| debug_query_id         | bigint                  | 唯一SQL ID。部分语句存在不唯一的情况，如Parse报文、DCL和TCL等语句的debug_query_id值为0。存储过程内的语句使用同一个ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | L0                                                                   |
| query                   | text                      | 归一化SQL，track_stmt_parameter参数开启时，显示完整SQL。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | L0                                                                    |
| start_time            | timestamp with time zone | 语句启动的时间。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | L0                                                                    |
| finish_time             | timestamp with time zone  | 语句结束的时间。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | L0                                                                   |
| slow_sql_threshold     | bigint                 | 语句执行时慢SQL的标准。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | L0                                                                   |
| transaction_id         | bigint                   | 事务ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | L0                                                                     |
| thread_id             | bigint                  | 执行线程ID。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | L0                                                                    |
| session_id             | bigint                 | 用户session id。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | L0                                                                   |
| n_soft_parse          | bigint                    | 软解析次数，n_soft_parse + n_hard_parse可能大于n_calls，因为子查询未计入n_calls。（该字段对非DML语句无意义）                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | L0                                                                    |
| n_hard_parse            | bigint                    | 硬解析次数，n_soft_parse + n_hard_parse可能大于n_calls，因为子查询未计入n_calls。对复杂数据类型的解析也会额外增加解析次数，例如smalldatetime。（该字段对非DML语句无意义）                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | L0                                                                    |
| query_plan           | text                    | 语句执行计划。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | L1(Full SQL) L0(Slow SQL) |
| n_returned_rows        | bigint                   | SELECT返回的结果集行数。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | L0                                                                    |
| n_tuples_fetched      | bigint                   | 随机扫描行，即回表次数。回表是指在使用索引进行查询时，如果查询的列不在索引中，数据库引擎需要通过索引中的主键或唯一标识符再次访问主表以获取所需的完整数据行的过程。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | L0                                                                      |
| n_tuples_returned       | bigint                 | 顺序扫描行，通过顺序扫描获取的活动行数与通过索引扫描返回的索引条目数之和。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | L0                                                                    |
| n_tuples_inserted     | bigint                   | 插入行。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | L0                                                                      |
| n_tuples_updated          | bigint                    | 更新行。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | L0                                                                     |
| n_tuples_deleted        | bigint                    | 删除行。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | L0                                                                    |
| n_blocks_fetched         | bigint                    | buffer的块访问次数，表示从缓冲区和磁盘中读取block的总数。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | L0                                                                    |
| n_blocks_hit            | bigint                    | buffer的块命中次数，表示从缓冲区中读取block的数量。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | L0                                                                   |
| db_time                 | bigint                     | 有效的DB时间花费，多线程将累加（单位：微秒）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | L0                                                                   |
| cpu_time               | bigint                     | CPU消耗时间（单位：微秒）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | L0                                                                  |
| execution_time        | bigint                   | 执行器内执行时间（单位：微秒）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | L0                                                                   |
| parse_time              | bigint                   | SQL解析时间（单位：微秒）。（若解析阶段出现异常，不记录parse_time）                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | L0                                                                    |
| plan_time                | bigint                   | SQL生成计划时间（单位：微秒）。（若计划生成阶段出现异常，不记录plan_time）                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | L0                                                                     |
| rewrite_time          | bigint                 | SQL重写时间（单位：微秒）。（若重写阶段出现异常，不记录rewrite_time）                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | L0                                                                    |
| pl_execution_time     | bigint                  | plpgsql上的执行时间（单位：微秒）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | L0                                                                     |
| pl_compilation_time   | bigint                   | plpgsql上的编译时间（单位：微秒）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | L0                                                                  |
| data_io_time          | bigint                   | IO上的时间花费（单位：微秒）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | L0                                                                    |
| net_send_info           | text                       | 通过物理连接发送消息的网络状态，包含时间（微秒）、调用次数、吞吐量（字节），例如：{"time":xxx, "n_calls":xxx, "size":xxx}。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | L0                                                                  |
| net_recv_info        | text                    | 通过物理连接接收消息的网络状态，包含时间（微秒）、调用次数、吞吐量（字节），例如：{"time":xxx, "n_calls":xxx, "size":xxx}。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | L0                                                                   |
| net_stream_send_info   | text                     | 通过逻辑连接发送消息的网络状态，包含时间（微秒）、调用次数、吞吐量（字节）。集中式不支持该字段。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | L0                                                                  |
| net_stream_recv_info    | text                     | 通过逻辑连接接收消息的网络状态，包含时间（微秒）、调用次数、吞吐量（字节）。集中式不支持该字段。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | L0                                                                    |
| lock_count           | bigint                   | 加锁次数。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | L0                                                                   |
| lock_time             | bigint                  | 加锁耗时。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | L1                                                                     |
| lock_wait_count        | bigint                   | 加锁等待次数。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | L0                                                                    |
| lock_wait_time           | bigint                     | 加锁等待耗时。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | L1                                                                     |
| lock_max_count          | bigint                   | 最大持锁数量。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | L0                                                                     |
| lwlock_count         | bigint                   | 轻量级加锁次数（预留）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | L0                                                                      |
| lwlock_wait_count       | bigint                   | 轻量级加锁等待次数。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | L0                                                                    |
| lwlock_time            | bigint                    | 轻量级加锁时间（预留）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | L1                                                                   |
| lwlock_wait_time         | bigint                   | 轻量级加锁等待耗时。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | L1                                                                     |
| details                  | bytea                     | 等待时间、语句锁事件和GSTrace函数运行时间的列表。 记录级别的值\>=L0时，开始记录等待事件的列表。显示当前语句event等待相关的统计信息。具体事件信息请参见[表2](https://support.huaweicloud.com/centralized-ref-v10-gaussdb/gaussdb-38-1605.html#ZH-CN_TOPIC_0000002764460276__zh-cn_topic_0059777957_t794f802302c24514a5db22d51eabacc4)、[表3](https://support.huaweicloud.com/centralized-ref-v10-gaussdb/gaussdb-38-1605.html#ZH-CN_TOPIC_0000002764460276__table1647451092918)、[表4](https://support.huaweicloud.com/centralized-ref-v10-gaussdb/gaussdb-38-1605.html#ZH-CN_TOPIC_0000002764460276__table124603113369)和[表5](https://support.huaweicloud.com/centralized-ref-v10-gaussdb/gaussdb-38-1605.html#ZH-CN_TOPIC_0000002764460276__table11826123533718)。关于每种事务锁对业务的影响程度，请参见[LOCK](https://support.huaweicloud.com/centralized-ref-v10-gaussdb/gaussdb-38-0369.html)语法小节的详细描述。通过GStrace全链路跟踪函数，GStrace面板中的function字段表示函数名，以树形结构表达函数父子关系；GStrace面板中的duration字段表示函数运行时间，单位为微秒。 记录级别的值是L2时，开始记录语句锁事件的列表，该列表按时间顺序记录事件，记录的锁事件数量受参数track_stmt_details_size的影响。 该字段为二进制，需要借助解析函数pg_catalog.statement_detail_decode进行读取，请参见（[表16](https://support.huaweicloud.com/centralized-ref-v10-gaussdb/gaussdb-38-0083.html#ZH-CN_TOPIC_0000002764300032__table9745177191215)）。 事件包括： - 加锁开始 LOCK_START  - 加锁结束 LOCK_END  - 等锁开始 LOCK_WAIT_START  - 等锁结束 LOCK_WAIT_END  - 释放锁 LOCK_RELEASE  - 轻量级等锁开始 LWLOCK_WAIT_START  - 轻量级等锁结束 LWLOCK_WAIT_END   | L0/L2                                                                  |
| is_slow_sql             | boolean                    | 该SQL是否为slow SQL。 - t（true）：表示是。  - f（false）：表示不是。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | L0                                                                   |
| trace_id               | text                    | 驱动传入的trace id，与应用的一次请求相关联。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | L0                                                                    |
| advise                 | text                      | 可能导致该SQL为slow SQL的风险信息。 说明： - 如果语句通过SQLBypass方式执行（可通过explain查看计划判断），可以认为无慢SQL风险，本字段信息可能会缺失。  - 本字段长度限制256字符，如果超过256字符会被截断，先根据已有的提示信息进行SQL优化。  - advise涉及表别名的以表别名展示，涉及列别名的以列的原名展示。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | L0                                                                   |
| parent_unique_sql_id  | bigint                    | 当前语句的外层SQL的归一化SQL ID，对于存储过程内执行的语句，该值为调用存储过程语句的归一化SQL ID，存储过程外的语句该值为0。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | L0                                                                     |
| finish_status          | text                     | 语句完成状态。 - normal：表示正常。默认为normal。  - cancelled：表示被取消或被terminate。  - error：表示除cancelled外，其他异常导致的结束。   说明： 当语句完成状态不为normal时，表示语句执行异常，其他字段均无参考价值。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | L0                                                                  |
| used_memory            | integer                  | 单条语句内存使用量（单位：MB）。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | L0                                                                     |
| lock_max_local_count  | bigint                  | 经过locallock机制持锁的最大持锁数量。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | L0                                                                   |
| lock_max_fastpath_count | bigint                   | 经过fastpath机制持锁的最大持锁数量。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | L0                                                                    |
| lock_max_global_count | bigint                   | 经过主锁表持锁的最大持锁数量。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | L0                                                                    |
| sql_hash              | bigint                    | 当前SQL语句的哈希值。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | L0                                                                   |
| plan_hash               | bigint                   | 当前SQL计划的哈希值。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | L0                                                                      |
| plan_hash_prev          | bigint                   | 如果是Generic Plan，此值为上一次使用的计划的哈希值。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | L0                                                                   |
| driver_start_time        | timestamp with time zone   | JDBC驱动开始执行的时间点。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | L0                                                                   |
| driver_wait_response     | timestamp with time zone | JDBC驱动发送报文后的开始等待接收数据库返回数据的时间点。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | L0                                                                     |
| driver_finish_time        | timestamp with time zone   | JDBC驱动接收数据库返回数据完成的时间点。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | L0                                                                      |
| driver_info             | json                     | L0级别默认记录为"{}"。 L1级别开始，记录JDBC驱动各报文发送和接收的时间点。 参数track_stmt_stat_level修改后，会在新建立连接的会话生效，现有会话不生效。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | L1                                                                     |
| kernel_info             | json                     | 数据库各报文发送和接收的时间点。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | L0                                                                    |
| adaptive_join_states    | text                       | 记录自适应连接算子最终选用的连接方式，记录格式为\[plan_node_id, use_hashjoin\]，第一位代表对应的plan_node_id，第二位代表是否使用HashJoin，1代表是，0代表否。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | L0                                                                     |
| aplan_count            | bigint                   | aplan执行次数。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | L0                                                                     |
| aplan_parse_time        | bigint                    | aplan解析时间。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | L0                                                                     |
| aplan_execution_time    | bigint                     | aplan执行时间。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | L0                                                                     |
| relids                | text                     | 语句中涉及表的pg_class.oid，多表按","隔开。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | L0                                                                    |
   
![](https://support.huaweicloud.com/centralized-ref-v10-gaussdb/public_sys-resources/note_3.0-zh-cn.png)
- query_plan字段的记录级别对于Full SQL为L1，对于Slow SQL为L0。
- 对于db_time时间模型，在statement_history中各维度时间统计满足db_time \>= max(cpu_time, parse_time, plan_time, rewrite_time, data_io_time, net_send_info.time, net_recv_info.time, net_stream_send_info.time, net_stream_recv_info.time)。
- statement_history中的query字段来自unique sql hash table，获取query时会产生lwlock等待事件UniqueSQLMappingLock，此时db_time已经结束，该段时间不计入db_time中，因此当instr_unique_sql_count设置较大时可能出现lwlock_wait_time大于db_time的情况。
- 对于db_time时间模型公式，如下维度不纳入统计范围：
  - execution_time
  
  - pl_execution_time
  
  - pl_compilation_time
   
- 等待事件的嵌套深度最大值是20，如超过最大深度，新的等待事件会覆盖最后一次等待事件。
- adaptive_join_states只有在语句正常执行结束后才可上报，对于异常结束语句不进行上报。
- 如果当前执行计划是Generic Plan，则会记录非0的sql_hash和plan_hash，否则记录为0。
- 存储过程内语句CPU_TIME值为0。
- 当查询计划记录失败时，会在query_plan字段中提示记录失败的原因，如以下场景：
  - 非DML/DQL语句不记录计划。提示："Do not record plans for non-DML/DQL statements."。
  
  - 存储过程中未适配或没有计划的子语句，例如简单表达式、OPEN CURSOR、CLOSE以及BYPASS路径语句，不记录计划。提示："Statement has no plan or is unsupported for plan recording."。
  
  - 对于进入到PARSE阶段的SQL，还未生成计划，将不进行记录。提示："This statement is a PARSE statement and has not yet generated a query plan."。
  
  - 在检查是否需要上报query_plan时，SQL语句执行并不慢，后续清理等任务影响导致SQL语句整体执行慢。提示："Check the reported query_plan time is 2026-01-01 08:05:01.735619+08, at this time the SQL is not slow."。
  
  - 语句执行状态异常时，计划记录有可能失败，需要检查日志分析原因。提示："An error occurred during statement execution. Please check the log for analysis."。
  
  - 其他未记录成功的场景，需要检查日志分析原因。提示："The query plan failed to be recorded. Please check the log analysis."。
   
 
