Evidence collection

Read the collector before you run it.

The investigation starts from a read-only psql script that your team runs and reviews. No credentials leave your environment, and nothing is installed.

How to run it

psql "host=... dbname=... user=..." -X -f pg-evidence-collector.sql -o evidence.txt
  • Use a dedicated role whose permissions your DBA has reviewed. pg_monitor may expose broader statistics than this collection needs, and does not guarantee access to every optional view on every platform. Test permissions before a client run.
  • The script sets default_transaction_read_only = on, a 30-second statement_timeout and a 1-second lock_timeout for its own session.
  • Designed for PostgreSQL 13 and later. Tested against PostgreSQL 14 and 17 with a pg_monitor role. RDS and Aurora still require platform-specific review and have not been tested here.
  • Run it once during a normal period and, if you can, once while the problem is happening.

What it collects

SectionSourceWhy
Server and settingsversion(), pg_settings (non-default only), extensionsContext for every other number
Database activitypg_stat_databaseCache hit ratio, temp files, rollbacks, deadlocks
Top statementspg_stat_statements, top 50 by total timeWhere database time actually goes
Tables and indexespg_stat_user_tables, pg_stat_user_indexesSize, scan patterns, dead tuples, vacuum and analyze timing, unused indexes
Connections and waitspg_stat_activity, pg_blocking_pids()Pool behaviour, idle transactions, current blocking
Maintenance healthTransaction ID age, checkpoints, replication slots, vacuum progressProblems that build up slowly before they hurt

What it does not collect

  • No table data. It reads only statistics and catalog views.
  • No passwords or connection strings.
  • pg_stat_statements usually normalizes constants, but statement text and identifiers can still reveal sensitive context. The current-activity section can include literal values.

Review before you send

The output is a plain text file. Read it first. Table, column and index names appear throughout, and the current-activity section includes the first 120 characters of running queries, which can contain literal values. Delete or redact anything you are not comfortable sharing; the investigation notes what was removed.

What else helps

  • Representative EXPLAIN (ANALYZE, BUFFERS) output for the slow requests, from a safe environment.
  • A short timeline: when the symptom started, plus deploys, migrations and configuration changes around it.
  • On RDS or Aurora: Database Insights and CloudWatch exports for the same window. See what each source answers.
Production evidence

Need an independent PostgreSQL investigation?

Start with the problem and the evidence you already have. You will get a direct answer on whether a scoped investigation is the right next step.

Prefer to talk first? Book a 20-minute triage call.