Home

Awesome

pg_insights

Convenient SQL for monitoring Postgres database health. This repository is inspired by commands from Heroku's pg_extras repository.

How to Use

psql

You can run a script using psql's -f option. For example:

$ psql postgres -f sql/cache_hit_rate.sql

It also works with aliases you have setup with psql:

$ alias psql_my_db="psql -h my_db.com -d my_db -U admin"
$ psql_my_db -f sql/cache_hit_rate.sql

Other

You can also copy/paste any of the SQL in the sql/ directory and run with the Postgres client of your choice.

Scripts

active_autovacuums.sql (admin permission)

analyze_stats.sql (read permission)

bloat.sql (read permission)

buffer_cache_usage.sql (admin permission)

cache_hit_rate.sql (read permission)

index_hit_rate.sql (read permission)

index_size.sql (read permission)

reset_stats.sql (admin permission)

table_settings.sql (read permission)

table_size.sql (read permission)

table_size_with_indices.sql (read permission)

toast_size.sql (read permission)

unused_indices.sql (read permission)

vacuum_stats.sql (read permission)

Contributing

Pull requests for bug fixes, improvements, or new SQL are always welcome!