PgHero

:tada: Database insights made easy

View the demo

Screenshot

Supports PostgreSQL 9.2+

For pure SQL, check out PgHero.sql

:clap: Initial queries and inspiration by Heroku

Installation

Add this line to your application’s Gemfile:

gem 'pghero'

And mount the dashboard in your router.

mount PgHero::Engine, at: "pghero"

Be sure to protect the dashboard in production.

Insights

PgHero.running_queries
PgHero.long_running_queries
PgHero.index_usage
PgHero.missing_indexes
PgHero.unused_indexes
PgHero.unused_tables
PgHero.database_size
PgHero.relation_sizes
PgHero.index_hit_rate
PgHero.table_hit_rate

# kill queries
PgHero.kill(pid)
PgHero.kill_all

Security

Basic Authentication

Set the following variables in your environment or an initializer.

ENV["PGHERO_USERNAME"] = "andrew"
ENV["PGHERO_PASSWORD"] = "secret"

Devise

authenticate :user, lambda {|user| user.admin? } do
  mount PgHero::Engine, at: "pghero"
end

TODO

  • better explanations on dashboard
  • use pg_stat_statements extension for more detailed insights
  • poll for running queries
  • better design (no bootstrap)

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help: