View statistics information
PolarDB for PostgreSQL (PolarFlex) provides a rich set of system views and system tables for viewing statistics information collected from monitoring.
System views
View name | Description |
Displays one row for each server process. The row shows information about the current activity of the process, such as its status and current query. | |
pg_stat_replication | Displays one row for each Write-Ahead Logging (WAL) sender process. The row shows statistics about replication to the standby server connected to that sender. |
pg_stat_wal_receiver | Displays only one row. The row shows statistics about the receiver from the server to which the WAL receiver is connected. |
pg_stat_subscription | Displays at least one row for each subscription. The row shows information about the workers for that subscription. |
pg_stat_ssl | Displays one row for each connection, regular or replication. The row shows information about the SSL used on the connection. |
pg_stat_progress_vacuum | Displays one row for each running VACUUM backend process, including |
Statistics collection results views
View name | Description |
pg_stat_archiver | Displays only one row. The row shows statistics about the activity of the WAL archiver process. |
pg_stat_bgwriter | Displays only one row. The row shows statistics about the activity of the background writer process. |
pg_stat_database | Displays one row for each database. The row shows database-wide statistics. |
pg_stat_database_conflicts | Displays one row for each database. The row shows database-wide statistics about queries that were canceled because of conflicts with recovery on standby nodes. |
pg_stat_all_tables | Displays one row for each table in the current database. The row shows statistics about access to the specified table. |
pg_stat_sys_tables | Shows statistics about access to system tables. |
pg_stat_user_tables | Shows statistics about access to user tables. |
pg_stat_xact_all_tables | Similar to |
pg_stat_xact_sys_tables | Same as |
pg_stat_xact_user_tables | Same as |
pg_stat_all_indexes | Displays one row for each index in the current database. The row shows statistics about access to the specified index. |
pg_stat_sys_indexes | Same as |
pg_stat_user_indexes | Same as |
pg_statio_all_tables | Displays one row for each table in the current database, including TOAST tables. The row shows statistics about I/O on the specified table. |
pg_statio_sys_tables | Same as |
pg_statio_user_tables | Same as |
pg_statio_all_indexes | Displays one row for each index in the current database. The row shows statistics about I/O on the specified index. |
pg_statio_sys_indexes | Same as |
pg_statio_user_indexes | Same as |
pg_statio_all_sequences | Displays one row for each sequence in the current database. The row shows statistics about I/O on the specified sequence. |
pg_statio_sys_sequences | Same as Note No system sequences are currently defined, so this view is empty. |
pg_statio_user_sequences | Same as |
pg_stat_user_functions | Displays one row for each tracked function. The row shows statistics about the execution of that function. For all tracked functions, the following fields are returned: function OID, schema, name, number of calls, total time, and self time. Self time is the amount of time spent in the function itself. Total time includes the time spent in functions that it calls. Time values are in milliseconds. |
pg_stat_xact_user_functions | Similar to |
The pg_statio_ family of views is primarily used to assess the effectiveness of the buffer. When the number of actual disk reads is much smaller than the number of buffer hits, the buffer can satisfy most read requests without making kernel calls. However, these statistics do not provide a complete picture. Because of how PolarDB handles disk I/O, data blocks that are not in the buffer may still reside in the kernel's I/O cache. Therefore, they can be read again without a physical disk read. To understand the I/O behavior of PolarDB in more detail, use the PolarDB statistics collector together with operating system tools that let you observe how the kernel handles I/O.
System tables
PolarDB for PostgreSQL (PolarFlex) provides the pg_locks system table to monitor database activity. This table allows database administrators to view information about unresolved locks in the lock manager.
This table can be used in the following common scenarios:
View all current unresolved locks, all locks on relations in a specific database, all locks on a specific relation, or all locks held by a specific PostgreSQL session.
Identify the relations in the current database that have the most ungranted locks. These relations are likely sources of contention for database clients.
Determine the impact of lock contention on overall database performance and how lock contention changes with the overall database traffic.
Appendix
pg_stat_activity
This section provides detailed explanations of the fields returned by this view.
Column name | Data type | Description |
datid | OID | The OID of the database that this session is connected to. |
datname | NAME | The name of the database that this session is connected to. |
pid | INTEGER | The process ID of this session. This is a unique identifier for the current session. |
usesysid | OID | The OID of the user connected to this session. |
usename | NAME | The name of the user connected to this session. |
application_name | TEXT | The name of the application connected to this session. |
client_addr | INET | The IP address of the client. If this field is empty, it indicates that the client is connected through a Unix socket on the server machine or it is an internal process, such as autovacuum. |
client_hostname | TEXT | The hostname of the client, as reported by a reverse DNS lookup of |
client_port | INTEGER | The port number of the client. The value is -1 if a Unix socket is used. |
backend_start | TIMESTAMP WITH TIME ZONE | The time when this session process started. This is the timestamp when the session connected to the database. |
xact_start | TIMESTAMP WITH TIME ZONE | The time when the current transaction started. This is NULL if no transaction is active. If the current query is the first in its transaction, this column is equal to |
query_start | TIMESTAMP WITH TIME ZONE | The time when the currently running query started. If the |
state_change | TIMESTAMP WITH TIME ZONE | The time when the session state was last changed. |
wait_event_type | TEXT | The type of event the session is currently waiting for. This is NULL if the session is not waiting. Possible values include the following:
|
wait_event | TEXT | The specific event the session is currently waiting for. This is NULL if the session is not waiting. |
state | TEXT | The current status of the session. Possible values include the following:
|
backend_xid | XID | The top-level transaction identifier of this session, if any. |
backend_xmin | XID | The |
query | TEXT | The text of the most recent query for this session. If |
backend_type | TEXT | The type of this session. Possible values include the following: |