Easy-to-deploy, open source PostgreSQL health-check SQL function
curl -fsSL https://raw.githubusercontent.com/randoneering/pgFirstAid/main/pgFirstAid.sql | psql -d YOUR_DBThen: SELECT * FROM pg_firstAid();
A single SQL function and view that gives you a prioritized list of actions to improve your PostgreSQL database’s stability and performance.
Inspired by Brent Ozar’s FirstResponderKit for SQL Server, but built for Postgres, by people who run Postgres in production.
pg_stat_statements Checks - Runs additional query workload checks when that extension is installedcurl -fsSL https://raw.githubusercontent.com/randoneering/pgFirstAid/main/pgFirstAid.sql | psql -d YOUR_DB
Then run it (the function is the primary interface; a view is also available):
--- function
SELECT * FROM pg_firstAid();
--- view
SELECT * FROM v_pgfirstAid;
-- Show only critical issues
SELECT * FROM pg_firstAid() WHERE severity = 'CRITICAL';
SELECT * FROM v_pgfirstAid WHERE severity = 'MEDIUM';
-- Show critical and high priority issues
SELECT * FROM pg_firstAid() WHERE severity IN ('CRITICAL', 'HIGH');
SELECT * FROM v_pgfirstAid WHERE severity IN ('CRITICAL', 'HIGH');
Categories: Table Health, Query Health, Replication Health, System Health, Database Health
-- Check table health
SELECT * FROM v_pgfirstAid WHERE category = 'Table Health';
SELECT severity, COUNT(*) as issue_count
FROM pg_firstAid()
GROUP BY severity
ORDER BY MIN(CASE severity
WHEN 'CRITICAL' THEN 1
WHEN 'HIGH' THEN 2
WHEN 'MEDIUM' THEN 3
WHEN 'LOW' THEN 4
ELSE 5 END);
pgFirstAid is supported by DigitalOcean, Neon, and the OSU Open Source Lab. Their sponsorship covers testing infrastructure and CI/CD pipelines that keep pgFirstAid reliable.
FirstResponderKit - Brent Ozar’s pioneering health-check suite for SQL Server.
pgFirstAid is supported by: