PostgreSQL performance monitoring that shows what changed
PostgreSQL performance monitoring built on pg_stat_statements: hour-of-day baselines, query regression flags with evidence, and fix scripts like CREATE INDEX CONCURRENTLY with undo. Works on RDS and Aurora. First database free.
Transcript
Find a slow PostgreSQL query with hour-of-day baselines. A release went out and one query got 9x slower. Here is how ReinDB spots it, explains it and writes the fix.
This is the Fleet view: four demo databases, worst first.
BANDLEI_PG is degraded: its load is 2.3x the usual for this hour of day.
The Drift page lists every flag ReinDB raised, most serious first.
One statement is 9x slower per execution: 180 ms now against a typical 20 ms.
"Typical" means the same hour of day on earlier days, so a busy Monday morning is not a false alarm.
It also does 38x more work per execution (4,200 buffers vs 110). That points to a plan change, not a busy server.
Statement drift: average, typical and latest time per statement, and the extra busy seconds per hour it costs now (575).
Click the statement id to open it.
Where the time goes: I/O wait against CPU, from pg_stat_statements, one bar per 6 hours.
Time per execution over the week. The blue markers are events, such as deploys, so a jump sits next to its likely cause.
Release 4.2 went out at 13:08. The next hour, this query was 9x slower.
The analysis reads the catalog and the plan now. It only reads: statistics, catalog and plan, never table rows.
No index on orders starts with member_id, status, so every call scans all 4.2 million rows.
Each finding names the table and columns, and says what usually fixes it.
The fix comes as a script with every line commented out: review it, test it, then uncomment it. Each step has an undo.
There is a test kit too, to prove the fix on a copy before production. That is the next video.
Baselines compares any period with the usual for the same hours, or with a period you saved.
Over the week, this statement cost the most extra time against its baseline.
See it on the live demo at reindb.com. Read-only. Nothing installed in the database. PostgreSQL, MySQL, SQL Server and Oracle.
Built on pg_stat_statements
ReinDB reads the statistics PostgreSQL already keeps, with the pg_monitor role. From pg_stat_statements it takes time, buffer and disk reads, temp spill and WAL per statement. It also uses pg_stat_monitor (which adds plan-change flags), pg_wait_sampling, pg_qualstats and track_io_timing when they are there. The connection test lists every statistic as OK, missing or optional, with the exact command or parameter-group setting to turn it on.
Versions 12 to 18, with 19 in preview. Tested on Amazon RDS for PostgreSQL and Aurora PostgreSQL; on Aurora, where WAL lives in AWS's storage layer, ReinDB points you to CloudWatch for it.
What it flags
Every hour (or every 30 or 15 minutes) ReinDB measures each statement's time and reads since the last run and compares them with the median and spread for the same hour of the day over the last 14 days. Monday 9 AM is judged against other 9 AMs, not against 3 AM, so the batch peak is normal and a real regression stands out.
- Query regressions: a statement now slower per call than its usual for the hour, sized by the extra time it costs.
- New heavy statements and execution spikes.
- Database-wide drift: load, waits and WAL, dead rows and vacuum against their usual.
- Each flag is NEW, ONGOING or RESOLVED, with the evidence on a chart and, if you mark deploys, the deploy next to it.
Ask in plain English (“load over the last 3 days”, “what flags fired this week?”) and the chart and caption come from the stored measurements.
Fix scripts a DBA can test
For the worst regressions ReinDB reads the plan and explains why the statement is slow: missing indexes, temp spills, disk-bound reads, rows examined per row returned, N+1 patterns, planning and JIT overhead. The fix comes as a script for change control, such as CREATE INDEX CONCURRENTLY or a per-role setting, with every line commented out and every step paired with its undo. It never runs by itself. On RDS and Aurora a fix never says ALTER SYSTEM; it names the parameter group setting, the aws rds command and whether it needs a reboot.
It also reviews the database itself: cache hit ratio, dead rows and vacuum, never-analyzed tables, unused indexes, forced checkpoints, replication slots holding WAL and idle-in-transaction sessions.
Prove the fix, then watch it
Beside a fix script, download a test kit for its index and statistics steps: prerequisite checks, before and after runs, go live, rollback and cleanup. Compare reads the two result files and shows times, reads, plans, a results checksum and a verdict. After the change, mark the fix and ReinDB compares the statement's time and reads before and after, and flags a new plan or the regression coming back.
Hosted, on-premises or air-gapped
Use it hosted (nothing to install; ReinDB connects over TLS with a read-only user from one fixed address), on your own Linux or Windows server for databases that never leave your network, including air-gapped ones, or deployed into your own AWS or Google Cloud account. See deployment options and pricing: your first database is free, with no time limit.
Read more
- Which table changed its habits? An hour-of-day baseline for pg_stat_user_tables
- Guide: database performance baselines
- Guide: the SQL statement tuning procedure
- Guide: indexing, when, where and which type
Or check a database once first, with no account: the free database health check.