Vacuum is a PostgreSQL monitoring package for Laravel from Rati Rukhadze. It reads the statistics PostgreSQL already keeps in views such as pg_stat_user_tables, pg_stat_activity, and pg_stat_statements, then lists the problems it finds along with the SQL statement that would fix them.
Here's the main features this package provides:
- 13 advisor rules: wraparound, bloat, dead tuples, unused indexes, slow statements, and more
- Health score: a grade out of 100, based on the findings
- Blade and Filament Support: a dashboard at
/vacuum, or a Filament 4 or 5 plugin - A vacuum:check Command: fails a build on critical findings
- A vacuum:lint Command: flags schema problems like unindexed foreign keys in CI
- History: trends and forecasts from scheduled snapshots
- Lessons: 13 PostgreSQL explainers that use your own tables
- And more...
The Dashboard and Advisor Rules
Every finding has a severity and grade, giving you a health score out of 100:
You can learn more about the rules from the package's readme. The package also provides a /learn endpoint that tells you why issues exist in your database using your own tables as working examples, such as N+1 queries.
The same rules run from the terminal:
php artisan vacuum:checkphp artisan vacuum:check --fail-on=warning # critical, warning, info, or neverphp artisan vacuum:check --format=json # score, grade, deductions, findings
Using a scheduled job against staging, you could use the above commands to fail when a table's freeze age crosses the critical threshold. Each rule reads its limits from config/vacuum.php, including dead_tuple_ratio (0.20) and slow_query_milliseconds (500).
Installation
Vacuum 1.2.0 requires PostgreSQL 14 and Laravel 11+. The pg_stat_statements extension is optional. Without it, the dashboard tells you the extension is missing.
composer require heyosseus/vacuumphp artisan vacuum:install
The dashboard opens only in the local environment. To access it in other environments, you can write a callback using the Vacuum::auth() method:
use Heyosseus\Vacuum\Vacuum; Vacuum::auth(fn (Request $request) => $request->user()?->isAdmin() === true);
You can learn more about this package, get full installation instructions, and view the source code on GitHub.