STATEMENT_HISTORY
Displays information about statements executed on the current node. To query this system catalog, you must have the sysadmin permission. The result can be queried only in the system database but cannot be queried in the user database.
- Data must be queried in the Postgres database. No data exists in other databases.
- This system catalog is controlled by track_stmt_stat_level. The default value is OFF,L0, where the first part controls full SQL statements, and the second part controls slow SQL statements. For details about the record level of each column, see the following table. To ensure system performance, you are advised to use the SET statement to change the value of this parameter so that the parameter takes effect only for the current session.
- For slow SQL statements, if the value of track_stmt_stat_level is not OFF and the SQL execution time exceeds the value of log_min_duration_statement, the SQL statement is recorded as a slow SQL statement.
Name |
Type |
Description |
Record Level |
---|---|---|---|
db_name |
name |
Database name. |
L0 |
schema_name |
name |
Schema name. |
L0 |
origin_node |
integer |
Node name. |
L0 |
user_name |
name |
Username. |
L0 |
application_name |
text |
Name of the application that sends a request. |
L0 |
client_addr |
text |
IP address of the client that sends a request. |
L0 |
client_port |
integer |
Port number of the client that sends a request. |
L0 |
unique_query_id |
bigint |
ID of the normalized SQL statement. |
L0 |
debug_query_id |
bigint |
ID of the unique SQL statement. Some statements are not unique. For example, the value of debug_query_id in the Parse packet, DCL statements, and TCL statements is 0. |
L0 |
query |
text |
Normalized SQL statement. When the track_stmt_parameter parameter is enabled, the complete SQL statement is displayed. |
L0 |
start_time |
timestamp with time zone |
Time when a statement starts. |
L0 |
finish_time |
timestamp with time zone |
Time when a statement ends. |
L0 |
slow_sql_threshold |
bigint |
Standard for slow SQL statement execution. |
L0 |
transaction_id |
bigint |
Transaction ID. |
L0 |
thread_id |
bigint |
ID of an execution thread. |
L0 |
session_id |
bigint |
Session ID of a user. |
L0 |
n_soft_parse |
bigint |
Number of soft parsing times. The value of n_soft_parse plus the value of n_hard_parse may be greater than the value of n_calls because the number of subqueries is not counted in the value of n_calls. |
L0 |
n_hard_parse |
bigint |
Number of hard parsing times. The value of n_soft_parse plus the value of n_hard_parse may be greater than the value of n_calls because the number of subqueries is not counted in the value of n_calls. |
L0 |
query_plan |
text |
Statement execution plan. |
L1(Full SQL) L0(Slow SQL) |
n_returned_rows |
bigint |
Number of rows in the result set returned by the SELECT statement. |
L0 |
n_tuples_fetched |
bigint |
Number of rows randomly scanned. |
L0 |
n_tuples_returned |
bigint |
Number of rows sequentially scanned. |
L0 |
n_tuples_inserted |
bigint |
Number of rows inserted. |
L0 |
n_tuples_updated |
bigint |
Number of rows updated. |
L0 |
n_tuples_deleted |
bigint |
Number of rows deleted. |
L0 |
n_blocks_fetched |
bigint |
Number of buffer block access times. |
L0 |
n_blocks_hit |
bigint |
Number of buffer block hits. |
L0 |
db_time |
bigint |
Valid DB time, which is accumulated if multiple threads are involved (unit: μs). |
L0 |
cpu_time |
bigint |
CPU time (unit: μs). |
L0 |
execution_time |
bigint |
Execution time in the executor (unit: μs). |
L0 |
parse_time |
bigint |
SQL parsing time (unit: μs). |
L0 |
plan_time |
bigint |
SQL plan generation time (unit: μs). |
L0 |
rewrite_time |
bigint |
SQL rewriting time (unit: μs). |
L0 |
pl_execution_time |
bigint |
Execution time of PL/pgSQL (unit: μs). |
L0 |
pl_compilation_time |
bigint |
Compilation time of PL/pgSQL (unit: μs). |
L0 |
data_io_time |
bigint |
I/O time (unit: μs). |
L0 |
net_send_info |
text |
Network status of messages sent through a physical connection, including the time (unit: μs), number of calls, and throughput (unit: byte). This column is not supported in the centralized system. |
L0 |
net_recv_info |
text |
Network status of messages received through a physical connection, including the time (unit: μs), number of calls, and throughput (unit: byte). This column is not supported in the centralized system. |
L0 |
net_stream_send_info |
text |
Network status of messages sent through a logical connection, including the time (unit: μs), number of calls, and throughput (unit: byte). This column is not supported in the centralized system. |
L0 |
net_stream_recv_info |
text |
Network status of messages received through a logical connection, including the time (unit: μs), number of calls, and throughput (unit: byte). This column is not supported in the centralized system. |
L0 |
lock_count |
bigint |
Number of locks. |
L0 |
lock_time |
bigint |
Time required for locking. |
L1 |
lock_wait_count |
bigint |
Number of lock waits. |
L0 |
lock_wait_time |
bigint |
Time required for lock waiting. |
L1 |
lock_max_count |
bigint |
Maximum number of locks. |
L0 |
lwlock_count |
bigint |
Number of lightweight locks (reserved). |
L0 |
lwlock_wait_count |
bigint |
Number of lightweight lock waits. |
L0 |
lwlock_time |
bigint |
Time required for lightweight locking (reserved). |
L1 |
lwlock_wait_time |
bigint |
Time required for lightweight lock waiting. |
L1 |
details |
bytea |
List of wait events and statement lock events. When the value of the record level is greater than or equal to L0, the list of wait events starts to be recorded. Statistics about the wait events of the current statement are displayed. For details about events, see Table 2, Table 3, Table 4, and Table 5. For details about the impact of each transaction lock on services, see LOCK. When the value of track_stmt_stat_level is L2, the list of statement lock events starts to be recorded. The list records events in chronological order. The number of records is determined by the track_stmt_details_size parameter. This column is in binary format and needs to be read by using the parsing function pg_catalog.statement_detail_decode. For details, see Table 8. Events include:
|
L0/L2 |
is_slow_sql |
Boolean |
Specifies whether the SQL statement is a slow SQL statement.
|
L0 |
trace_id |
text |
Driver-specific trace ID, which is associated with an application request. |
L0 |
advise |
text |
Risk information that may cause the SQL statement to be a slow SQL statement. |
L0 |
parent_unique_sql_id |
bigint |
Normalized SQL ID of the outer SQL statement. For statements executed in a stored procedure, the value is the normalized SQL ID of the statement that invokes the stored procedure. For statements outside the stored procedure, the value is 0. |
L0 |
finish_status |
text |
Statement completion status.
|
L0 |
- The record level of the query_plan column is L1 for full SQL statements and L0 for slow SQL statements.
- For the db_time time model, the time statistics of each dimension in statement_history meet the requirement that db_time is greater than or equal to 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).
- For the db_time time model formula, the following dimensions are not included in the statistical accuracy scope:
- execution_time
- pl_execution_time
- pl_compilation_time
- The maximum nesting depth of wait events is 20. If the nesting depth exceeds 20, a new wait event overwrites the last wait event.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot