Content CheatsheetPostgreSQL
Content CheatsheetPostgreSQL
Content CheatsheetPostgreSQL
Note:
ʒ To query these metrics, you must be logged into PostgreSQL as a user that has read access to pg_stat_database
ʒ For more info on monitoring PostgreSQL performance, read http://dtdg.co/monitor-postgres
Rows returned by queries (per database) SELECT datname, tup_returned FROM pg_stat_database; Show location of postgresql.conf file1 SHOW config_file;
Bytes written temporarily to disk to execute SELECT datname, temp_bytes FROM pg_stat_database; Show location of data directory1 SHOW data_directory;
queries (per database)*
Show location of log directory (may be a SHOW log_directory;
path relative to data directory)1
List all databases \l
Write query throughput and performance metrics—more info List all tables + table size in bytes in the \dt+
METRIC DESCRIPTION QUERY current database
Rows inserted, updated, deleted by queries SELECT datname, tup_inserted, tup_updated, tup_deleted FROM List all roles and privileges in the current database \du
(per database) pg_stat_database;
Check if this server is a standby (in recovery mode) SELECT pg_is_in_recovery();
Rows inserted, updated, deleted by queries SELECT relname, n_tup_ins, n_tup_upd, n_tup_del FROM pg_stat_user_tables;
(per table) View connection info \conninfo
Heap-only tuple (HOT) updates (per table) SELECT relname, n_tup_hot_upd FROM pg_stat_user_tables; Show all available psql commands \?
Total commits and rollbacks across all databases SELECT SUM(xact_commit) AS total_commits, SUM(xact_rollback) *Available in version 9.2+
AS total_rollbacks FROM pg_stat_database; 1
Requires superuser privileges
Deadlocks1 postgresql.deadlocks
Number of sequential scans (per table)* postgresql.seq_scans List all tables + table size in bytes in the current \dt+
database
Rows fetched by queries (per database) postgresql.rows_fetched
List all roles and privileges in the current database\du
Rows returned by queries (per database) postgresql.rows_returned
Check if this server is a standby (in recovery SELECT pg_is_in_recovery();
Bytes written temporarily to disk to execute postgresql.temp_bytes mode)
queries (per database)1
View connection info \conninfo
Show all available psql commands \?
Monitor PostgresSQL Technology with Datadog Free START YOUR FREE TRIAL
Best-In-Class PostgresSQL
Monitoring
Start your free trial today and get real-time visibility into the health and
performance of your Postgres database—all in a matter of minutes.