-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marcus Gartner
committed
Oct 22, 2019
1 parent
285b722
commit 04e6661
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,34 @@ | ||
# pg_flame | ||
|
||
A flamegraph generator for Postgres `EXPLAIN ANALYZE` output. | ||
|
||
## Usage | ||
|
||
Generate an annotated query plan in JSON. | ||
|
||
``` | ||
psql lob_local -qAtc 'EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) SELECT id FROM bears' > plan.json | ||
``` | ||
|
||
Generate the flamegraph. | ||
|
||
``` | ||
cat plans.json | ./pg_flame > flamegraph.html | ||
``` | ||
|
||
Open `flamegraph.html` in a browser of your choice. | ||
|
||
## Background | ||
|
||
[Flamegraphs](http://www.brendangregg.com/flamegraphs.html) were invented by | ||
Brendan Gregg to visualize CPU consumption of profiled code-paths of software. | ||
They are useful visualization tools in many types of performance | ||
investigations. | ||
|
||
Luca Canali has previously shown the benefits of using flamegraph | ||
visualizations of Oracle query plans for debugging slow database queries. | ||
Pg_flame is in extension of that work for Postgres. | ||
|
||
This tool relies on the | ||
[`d3-flame-graph`](https://github.com/spiermar/d3-flame-graph) plugin to | ||
generate the flamegraph. |