Postgres Health Check (Free)

Find the Postgres problems that cause outages before they do, with one read-only command.

Postgres Health Check (Free) product illustration

What it does

One read-only command that checks a PostgreSQL database for the problems that cause outages and slowdowns, and tells you what to do about each.

pip install -r requirements.txt
python3 health_check.py --dsn postgresql://reader@localhost:5432/mydb
python3 health_check.py --md > health.md            # Markdown report (paste into a ticket)
python3 health_check.py --json                      # for scripts and dashboards
python3 health_check.py --fail-on critical          # exit 1 in CI / cron when something critical is found
python3 health_check.py --schema app                # only objects in one schema

No --dsn? It uses $DATABASE_URL or the usual libpq variables (PGHOST, PGUSER, PGDATABASE, PGPASSWORD). Passwords are redacted in every report.

What you get

The screenshot is real output from the kit’s own commands. Tested from a fresh download of this exact zip: ./run_tests.sh ran 7 tests OK on Python 3.13 and 3.10.

Real terminal output from Postgres Health Check: demo and passing tests

What it checks

SeverityCheck
criticalinvalid indexes (left by a failed CREATE INDEX CONCURRENTLY)
criticalsequences over 75% of their limit (inserts fail at 100%)
critical / warningtransaction ID wraparound over 75% / 50%
warningforeign keys without an index, duplicate indexes, tables without a primary key, tables with many dead rows, queries running over 5 minutes, never-analyzed tables, cache hit ratio under 95%, connections over 80% of max
infounused indexes, large tables read mostly by sequential scans
top 5 queries by total time (when pg_stat_statements is installed)

Every check runs in a READ ONLY transaction with a statement timeout. A check the user can't run (permissions, managed services) is listed as skipped instead of failing the report. A read-only role is enough; pg_monitor membership shows other users' queries.

Try it

./demo.sh plants one of each problem in schema demo_health of a scratch database (PGHC_DEMO_DSN) and checks it. ./run_tests.sh runs the unit tests anywhere, and the live tests when PGHC_TEST_DSN (and optionally PGHC_TEST_DSN14) point at scratch databases.

How it was tested

Tested against PostgreSQL 18.6 and 14.24 with Python 3.13 and 3.10: every planted problem found with the right severity, severity sorting, --fail-on exit codes, Markdown and JSON output, password redaction, and connection errors (exit 2).

Honest limits

  • Statistics count since the last stats reset or restart; on a fresh server "unused" means little. Check replicas separately: an index unused on the primary may serve replica reads.
  • It reports; it never changes anything. Drop or rebuild indexes yourself, preferably CONCURRENTLY.
  • No table/index bloat estimate (those queries are estimates and often wrong); dead-row counts are used instead.

Format and license

Zip, 21 KB, v1.0, 15 files. Free to use, modify and share for any purpose, including commercial work, as long as this notice stays in copies. Not affiliated with or endorsed by the PostgreSQL Global Development Group.

FAQ

Is it safe on production?
Yes: every query runs in a READ ONLY transaction with a timeout, and it only reads statistics views.
Which versions?
Tested on PostgreSQL 14 and 18; the views it uses exist in all supported versions.
Managed services (RDS, Supabase, Neon)?
Yes. Checks the role can't run are listed as skipped.
How do I get the files?
Click Download free. The zip downloads straight away: no checkout, no account.
Do I have to sign up for the newsletter?
No. The form is optional and the download works without it.

Get Postgres Health Check (Free)

Free read-only Postgres health check: invalid indexes, wraparound, sequences near limit, missing FK indexes, duplicate indexes and more. Markdown or JSON.

Pairs well with

Related

1 email a week: new x402 + MCP tools and free kits.

Short weekly digest of new x402 + MCP tools and free kits, including the MCP OAuth Checker. The download above works without signing up. No spam, unsubscribe any time.