STATEMENT_HISTORY
STATEMENT_HISTORY displays information about execution statements 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.
The constraints on the query of this system catalog are as follows:
- 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 field, see the following table.
- 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.
Table 1 STATEMENT_HISTORY columns
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. | |||
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. | |||
Number of rows in the result set returned by the SELECT statement. | |||
Valid DB time, which is accumulated if multiple threads are involved (unit: μs). | |||
Network status of messages sent through a physical connection, including the time (unit: μs), number of calls, and throughput (unit: byte). This can be used to analyze the network overhead of SQL statements in a distributed system and is not supported in standalone system. Example: {"time":xxx, "n_calls":xxx, "size":xxx}. | |||
Network status of messages received through a physical connection, including the time (unit: μs), number of calls, and throughput (unit: byte). This column can be used to analyze the network overhead of SQL in a distributed system. This column is not supported in a standalone mode. Example: {"time":xxx, "n_calls":xxx, "size":xxx}. | |||
Network status of messages sent through a logical connection, including the time (unit: μs), number of calls, and throughput (unit: byte). This column can be used to analyze the network overhead of SQL in a distributed system. This column is not supported in a standalone mode. Example: {"time":xxx, "n_calls":xxx, "size":xxx}. | |||
Network status of messages received through a logical connection, including the time (unit: μs), number of calls, and throughput (unit: byte). This column can be used to analyze the network overhead of SQL in a distributed system. This column is not supported in a standalone mode. Example: {"time":xxx, "n_calls":xxx, "size":xxx}. | |||
List of statement lock events, which are recorded in chronological order. The number of records is affected by the track_stmt_details_size parameter. This column is binary and needs to be read using the parsing function pg_catalog.statement_detail_decode. For details, see Table 6.
| |||
Whether the SQL statement is a slow SQL statement. | |||
Driver-specific trace ID, which is associated with an application request |