pg_dbwa
pg_dbwa · Analyzes local or remote PostgreSQL workloads using historical pg_stat_statements snapshots.
Overview
| Relationships | |
|---|---|
| Requires | dblink pg_eyes pg_prttn_tools pg_stat_statements plpgsql |
Usage
Sources:
pg_dbwa stores periodic pg_stat_statements snapshots and reports workload deltas for local or remote PostgreSQL databases. It is an old, SQL-only workload analyzer whose schema and dependencies require careful compatibility and security review before use.
Core Workflow
Version 0.3.1 declares hard dependencies on dblink, pg_stat_statements, pg_eyes, and pg_prttn_tools, and creates its objects in the dbwa schema:
dbwa.cluster_config records each monitored cluster and connection information. dbwa.cluster_operation selects snapshot operations. dbwa.get_stat(clustername) runs enabled operations and records their status. dbwa.show_top_queryes() ranks deltas over a time window, while dbwa.show_stat_query() returns interval deltas for one (userid, dbid, queryid).
Security and Compatibility
The reviewed SQL stores remote usernames and passwords in plain columns and constructs a dblink connection string from them. Restrict all dbwa tables and functions, protect backups, and prefer a minimally privileged monitoring role. Several functions are SECURITY DEFINER, concatenate configured operation names into dynamic SQL, and are owned by postgres; untrusted users must not be able to alter their configuration or search path.
The 0.3.1 install script uses legacy constructs such as WITH (OIDS=FALSE) and old pg_stat_statements columns. Verify installation against the exact PostgreSQL and dependency versions instead of assuming modern-server compatibility. Snapshot tables grow over time; schedule retention and account for the monitoring query load.