Easy to deploy, open source PostgreSQL function that provides a prioritized list of tasks to improve database stability and performance.
Inspired by Brent Ozer’s FirstResponderKit for SQL Server, PGFirstAid Designed for everyone to use—not just DBAs! Get actionable health information from your PostgreSQL database in seconds.
- zero dependency – Single SQL function, no external tools required
- thorough investigation – 12 (and growing!) built-in health checks that cover critical performance and stability issues
- priority results – Sort issues by severity (Critical → High → Medium → Low → Information)
- actionable recommendations – Each issue includes specific troubleshooting steps
- Documentation link – Direct links to official PostgreSQL documentation for deeper learning
-- Copy and paste the function definition into your PostgreSQL database
-- Then run it:
SELECT * FROM pg_firstAid();
That’s it! No configuration required. To avoid problems, deploy as a user with the highest possible privileges (in your environment).
| seriousness | Social class | check_name | object_name | Issue Description | current value | recommended Action | documentation_link |
|---|---|---|---|---|---|---|---|
| Serious | table structure | primary key is missing | public.user | Table is missing primary key… | no primary key defined | Add primary key or unique constraint… | https://www.postgresql.org/… |
| High | figures | missing statistics | public.order | The table was never analyzed… | Final analysis: never | Run ANALYZE on this table… | https://www.postgresql.org/… |
- missing primary keys – Tables without primary keys which can cause replication problems and poor performance
- unused large index – Indexes consume significant disk space but are never used (>10MB, 0 scans)
- table bloat – Tables with >20% bloat affecting performance (tables >100MB)
- missing statistics – Tables were never analyzed, leaving the query planner without statistics
- duplicate index – Multiple indexes with similar or overlapping column sets
- old data – Table statistics older than 7 days with significant modifications
- low index efficiency – Indices with poor selectivity (scan-to-tuple ratio >1000)
- highly sequential scan – Tables with high sequential scan activity that could benefit from indexes
- high connection count – More than 50 active connections potentially impacting performance
- missing foreign key index – Foreign key constraints without supporting indexes for efficient joins
- database size – Monitoring current database size and growth
- PostgreSQL version – Version information and configuration details
-- Show only critical issues
SELECT * FROM pg_firstAid() WHERE severity = 'CRITICAL';
-- Show critical and high priority issues
SELECT * FROM pg_firstAid() WHERE severity IN ('CRITICAL', 'HIGH');
-- Focus on index-related issues
SELECT * FROM pg_firstAid() WHERE category LIKE '%Index%';
-- Check table maintenance issues
SELECT * FROM pg_firstAid() WHERE category = 'Table Maintenance';
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);
- daily – Quick health check as part of morning routine
- before deployment – Catch potential issues before they impact production
- after major changes – Verify database health after schema modification or data migration
- display troubleshooting – First step when investigating slow queries or system problems
- capacity planning – Regular monitoring to keep track of database growth trends
read before acting
- Always review recommendations carefully before making changes. I’ve been supporting Postgres databases for nearly a decade, but I learn something new every day
- Test in non-production environment first
- Some operations (such as VACUUM FULL) require a maintenance window.
- Never drop an index without validating its usage patterns over time
permissions
- Requires read access to the system catalog (
pg_catalog, - Works with standard user permissions for most tests
- Some checks may yield fewer results for non-superuser accounts
pgFirstAid is designed to be lightweight and secure to run on production systems:
- Read-only operations (no modifications to your data or schema)
- Uses system catalog views that are already cached
- Typical execution time: <1 second on most databases
- No locking or blocking of user queries
- PostgreSQL 10+ – Fully supported, but only tested on 15+. This will change as the version becomes obsolete
- PostgreSQL 9.x – Most features work (may require minor syntax adjustments)
- Works with all PostgreSQL-compatible databases (Amazon RDS, Aurora, Azure Database, etc.).
Found any bugs? Do you have an idea for a new health checkup? tell me! I want this to be a tool that is available to everyone, casual DBA or not.
gplv3
Inspired by Brent Ozar’s FirstResponderKit for SQL Server. Thank you to the SQL Server community for pioneering accessible database health monitoring!
Dave-IYKYK
Built with ☕ for PostgreSQL and the open source community
sailing Montenegro rent a yacht in Montenegro
мстители смотреть ребёнок
шрек 4 парни с тату прямо в сердце
серіал не ідеальні жінки жизнь короля
турецький серіал далеке місто асі
Interested in UFC? https://ufc-white-house.com unique mixed martial arts tournament will take place on June 14, 2026, in Washington, D.C., on the South Lawn of the White House. It will be the first professional sporting event in history to be held directly on the grounds of the U.S. presidential residence.
Индивидуальные поездки с гидом купить экскурсию в Калининграде откроют лучшие места области в комфортном формате путешествия.
наруто смотреть наруто онлайн в хорошем
сколько стоит стоматология стоматология лечить
Пробелмы с финансами? https://financedirector.by анализ стратегий планирования, управления денежными потоками и инвестициями. Практические примеры, инструменты финансового менеджмента и эффективные решения для устойчивого развития бизнеса.
Быстрая профессиональная установка видеонаблюдения в калининграде для квартир, домов, офисов и коммерческих объектов. Проектирование, монтаж и настройка систем безопасности, удалённый доступ, запись видео и контроль в реальном времени. Надёжные решения для защиты имущества и контроля территории.
Steam Desktop Authenticator https://sdasteam.com (SDA). It allows you to generate account login codes and automatically confirm trades or item sales on the Community Market without using your smartphone.
Steam Desktop Authenticator https://steamdesktopauthenticator.net is a popular solution for Steam users who need access to Steam Guard features on their computer. It conveniently verifies actions, protects your account, and manages authentication in a single app.
песок карьерный с доставкой московская область песок карьерный цена м3 доставка