mgartner/pg_flame
mgartner/pg_flame has 1,622 GitHub stars and 36 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-08 03:24 UTC. Last push 2020-01-13.
A flamegraph generator for Postgres EXPLAIN ANALYZE output.
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Originalpg_flame

A flamegraph generator for Postgres EXPLAIN ANALYZE output.
Demo
Try the demo here.
Installation
Homebrew
You can install via Homebrew with the follow command:
$ brew install mgartner/tap/pg_flame
Download pre-compiled binary
Download one of the compiled binaries in the releases
tab. Once downloaded, move
pg_flame into your $PATH.
Docker
Alternatively, if you'd like to use Docker to build the program, you can.
$ docker pull mgartner/pg_flame
Build from source
If you'd like to build a binary from the source code, run the following commands. Note that compiling requires Go version 1.13+.
$ git clone https://github.com/mgartner/pg_flame.git
$ cd pg_flame
$ go build
A pg_flame binary will be created that you can place in your $PATH.
Usage
The pg_flame program reads a JSON query plan from standard input and writes
the flamegraph HTML to standard ouput. Therefore you can pipe and direct input
and output however you desire.
Example: One-step
$ psql dbname -qAtc 'EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) SELECT id FROM users' \
| pg_flame \
> flamegraph.html \
&& open flamegraph.html
Example: Multi-step with SQL file
Create a SQL file with the EXPLAIN ANALYZE query.
-- query.sql
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
SELECT id
FROM users
Then run the query and save the JSON to a file.
$ psql dbname -qAtf query.sql > plan.json
Finally, generate the flamegraph HTML.
$ cat plan.json | pg_flame > flamegraph.html
Example: Docker
If you've followed the Docker installation steps above, you can pipe query plan JSON to a container and save the output HTML.
$ psql dbname -qAtc 'EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) SELECT id FROM users' \
| docker run -i pg_flame \
> flamegraph.html
Background
Flamegraphs were invented by Brendan Gregg to visualize CPU consumption per code-path of profiled software. They are useful visualization tools in many types of performance investigations. Flamegraphs have been used to visualize Oracle database query plans and query executions , proving useful for debugging slow database queries.
Pg_flame is in extension of that work for Postgres query plans. It generates a visual hierarchy of query plans. This visualization identifies the relative time of each part of a query plan.
This tool relies on the
spiermar/d3-flame-graph plugin to
generate the flamegraph.
Explore related projects
Asabeneh/30-Days-Of-Python
The 30 Days of Python programming challenge is a step-by-step guide to learn the Python programming language in 30 days. This challenge may take more than 100 days. Follow your own pace. These videos may help too: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,303 starsgrafana/grafana
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
77,752 starsredis/redis
For developers, who are building real-time data-driven applications, Redis is the preferred, fastest, and most feature-rich cache, data structure server, and document and vector query engine.
77,268 starsapache/superset
Apache Superset is a Data Visualization and Data Exploration Platform
75,448 stars