pg_stat_statements is a PostgreSQL extension for collecting detailed SQL query statistics. It belongs in a monitoring setup alongside resource, activity, replication, transaction, backup, and storage metrics. section 7.4
Investigating an inherited database
When an inherited database has performance problems, inspect pg_stat_statements together with pg_stat_activity, database logs, and configuration. These signals can point toward application code, database design, configuration, or data-ingestion problems. section 11.3.3
Use pg_stat_statements as part of a broader operational practice:
- Track query behavior before resource starvation or other failures become urgent. section 7.4
- Combine query statistics with activity, wait, lock, I/O, and other monitoring data rather than treating one metric as a complete diagnosis. section 7.4
- Use findings to prioritize manageable improvements with measurable goals. section 11.3.3

