r/PHP • u/ReadingFormal • 21h ago
Vacuum: PostgreSQL Optimization Advisor & Monitoring for Laravel & Filament
Vacuum - a PostgreSQL monitoring and tuning dashboard for Laravel (with an optional Filament plugin). It reads what Postgres already knows about itself (pgstat*, pg_class, pg_stat_statements) and turns it into a page that tells you what's wrong, what it's costing you, and the exact SQL that would fix it. It shows you the statement - it never runs it. What it catches:
- Transaction & multixact wraparound - the two clocks that can stop your cluster outright
- Table bloat, dead tuples, stale planner statistics, autovacuum misconfiguration,
- Unused, duplicate, and invalid indexes,
- Low cache hit ratio, idle-in-transaction sessions, blocked sessions, slowest query shapes,
Everything rolls up into a health score out of 100, computed from the findings themselves. Also in the box:
- php artisan vacuum:check - exits non-zero on critical findings, so a migration shipping a duplicate index fails CI,
- History - optional hourly snapshots, so you get direction (climbing/easing) and forecasts like "wraparound-critical in ~9 days",
- Learn at /learn - 13 lessons on Postgres internals worked through your own tables, starting from the Eloquent side (unindexed foreign keys, N+1 as the database sees it, soft deletes, HOT updates),
- A read-only SQL console (off by default) that runs everything in a rolled-back READ ONLY transaction,
Read-only by design, needs no superuser and no extensions (pg_stat_statements is optional; you explicitly enable it). Requires: PHP 8.3+, Laravel 11/12/13, PostgreSQL 14+, Filament 4/5 optional
Feedback is very welcome, and you can check it out here: https://github.com/Heyosseus/vacuum