explaingit

ankane/pghero

8,860RubyAudience · ops devopsComplexity · 3/5Setup · moderate

TLDR

A web dashboard for monitoring and diagnosing PostgreSQL database health. See slow queries, unused indexes, and tables needing maintenance through a browser interface instead of running SQL commands manually.

Mindmap

mindmap
  root((pghero))
    What it does
      Slow query detection
      Index analysis
      Table maintenance alerts
    Installation
      Docker image
      Linux package
      Rails engine
    Related tools
      Dexter auto-indexer
      pgsync data copy
      pgslice partitioning
    Audience
      Database admins
      Rails developers
      DevOps teams
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Spot slow queries and missing indexes in a PostgreSQL database without writing SQL.

USE CASE 2

Embed a database health dashboard inside an existing Rails application.

USE CASE 3

Run PgHero as a Docker container to monitor any PostgreSQL instance from a browser.

Tech stack

RubyRuby on RailsPostgreSQLDocker

Getting it running

Difficulty · moderate Time to first run · 30min

Requires a running PostgreSQL database to connect to, the Rails engine option requires an existing Rails application.

In plain English

PgHero is a web dashboard that gives you a visual look at the health and performance of a PostgreSQL database. PostgreSQL (often shortened to Postgres) is a popular open-source database that many web applications use to store their data. Over time, databases can slow down because of missing indexes, long-running queries, bloated tables, or other issues, and diagnosing those problems normally requires running SQL commands and knowing what to look for. PgHero puts that information in a browser interface so it is easier to spot. The dashboard shows things like slow queries, duplicate indexes, unused indexes, and tables that need maintenance. It was used in production at Instacart, which gives some indication of how much load it has been tested against. You can install PgHero in three different ways depending on your setup. There is a Docker image for those who prefer containers, a Linux package for direct server installation, and a Rails engine for teams already running a Ruby on Rails application who want to embed the dashboard inside it. Each method has its own installation guide linked from the main README. The README itself is brief and points to separate guide files for setup details rather than listing them inline. It also lists a few related projects from the same author: Dexter for automatic index recommendations, pgsync for copying data between databases, and pgslice for table partitioning. PgHero is an open-source project that accepts contributions for bug fixes, documentation, and new features. A live demo is available at the project's hosted URL for anyone who wants to see what the interface looks like before installing it.

Copy-paste prompts

Prompt 1
I'm using ankane/pghero as a Rails engine. Show me how to mount it in my routes.rb and configure it to connect to my production PostgreSQL database.
Prompt 2
How do I run PgHero with Docker to connect to a PostgreSQL database running on the same host machine?
Prompt 3
I added PgHero to my Rails app and it's showing several slow queries. Walk me through how to interpret the results and decide which ones to fix first.
Prompt 4
How do I secure PgHero so it requires authentication before showing the dashboard?
Open on GitHub → Explain another repo

← ankane on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.