pgFirstAid

Easy-to-deploy, open source PostgreSQL health-check SQL function

GitHub stars

curl -fsSL https://raw.githubusercontent.com/randoneering/pgFirstAid/main/pgFirstAid.sql | psql -d YOUR_DB

Then: SELECT * FROM pg_firstAid();

What is pgFirstAid?

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.

Features

Install

curl -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):

--- functionSELECT * FROM pg_firstAid();--- viewSELECT * FROM v_pgfirstAid;

Filter by Severity

-- Show only critical issuesSELECT * FROM pg_firstAid() WHERE severity = 'CRITICAL';SELECT * FROM v_pgfirstAid WHERE severity = 'MEDIUM';-- Show critical and high priority issuesSELECT * FROM pg_firstAid() WHERE severity IN ('CRITICAL', 'HIGH');SELECT * FROM v_pgfirstAid WHERE severity IN ('CRITICAL', 'HIGH');

Filter by Category

Categories: Table Health, Query Health, Replication Health, System Health, Database Health

-- Check table healthSELECT * FROM v_pgfirstAid WHERE category = 'Table Health';

Count Issues by Severity

SELECT severity, COUNT(*) as issue_countFROM pg_firstAid()GROUP BY severityORDER BY MIN(CASE severity WHEN 'CRITICAL' THEN 1 WHEN 'HIGH' THEN 2 WHEN 'MEDIUM' THEN 3 WHEN 'LOW' THEN 4 ELSE 5 END);

Compatibility

Sponsors

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.

Inspired by

FirstResponderKit - Brent Ozar’s pioneering health-check suite for SQL Server.

News

Sponsors

pgFirstAid is supported by: