{"id":13466924,"url":"https://github.com/mgartner/pg_flame","last_synced_at":"2025-05-16T14:04:38.975Z","repository":{"id":40744873,"uuid":"215655521","full_name":"mgartner/pg_flame","owner":"mgartner","description":"A flamegraph generator for Postgres EXPLAIN ANALYZE output.","archived":false,"fork":false,"pushed_at":"2020-01-13T23:28:06.000Z","size":73,"stargazers_count":1590,"open_issues_count":2,"forks_count":37,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-12T10:59:07.791Z","etag":null,"topics":["database","flamegraph","performance","performance-visualization","postgres","postgresql","postgresql-tool"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mgartner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-16T22:27:00.000Z","updated_at":"2025-04-06T10:11:17.000Z","dependencies_parsed_at":"2022-08-19T17:13:04.605Z","dependency_job_id":null,"html_url":"https://github.com/mgartner/pg_flame","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgartner%2Fpg_flame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgartner%2Fpg_flame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgartner%2Fpg_flame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgartner%2Fpg_flame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgartner","download_url":"https://codeload.github.com/mgartner/pg_flame/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544146,"owners_count":22088807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","flamegraph","performance","performance-visualization","postgres","postgresql","postgresql-tool"],"created_at":"2024-07-31T15:00:51.434Z","updated_at":"2025-05-16T14:04:38.954Z","avatar_url":"https://github.com/mgartner.png","language":"Go","readme":"# pg_flame [![Version](https://img.shields.io/badge/version-v1.1-blue.svg)](https://github.com/mgartner/pg_flame/releases) [![Build Status](https://travis-ci.com/mgartner/pg_flame.svg?branch=master)](https://travis-ci.com/mgartner/pg_flame)\n\nA flamegraph generator for Postgres `EXPLAIN ANALYZE` output.\n\n\u003ca href=\"https://mgartner.github.io/pg_flame/flamegraph.html\"\u003e\n  \u003cimg width=\"700\" src=\"https://user-images.githubusercontent.com/1128750/67738754-16f0c300-f9cd-11e9-8fc2-6acc6f288841.png\"\u003e\n\u003c/a\u003e\n\n## Demo\n\nTry the demo [here](https://mgartner.github.io/pg_flame/flamegraph.html).\n\n## Installation\n\n### Homebrew\n\nYou can install via Homebrew with the follow command:\n\n```\n$ brew install mgartner/tap/pg_flame\n```\n\n### Download pre-compiled binary\n\nDownload one of the compiled binaries [in the releases\ntab](https://github.com/mgartner/pg_flame/releases). Once downloaded, move\n`pg_flame` into your `$PATH`.\n\n### Docker\n\nAlternatively, if you'd like to use Docker to build the program, you can.\n\n```\n$ docker pull mgartner/pg_flame\n```\n\n### Build from source\n\nIf you'd like to build a binary from the source code, run the following\ncommands. Note that compiling requires Go version 1.13+.\n\n```\n$ git clone https://github.com/mgartner/pg_flame.git\n$ cd pg_flame\n$ go build\n```\n\nA `pg_flame` binary will be created that you can place in your `$PATH`.\n\n## Usage\n\nThe `pg_flame` program reads a JSON query plan from standard input and writes\nthe flamegraph HTML to standard ouput. Therefore you can pipe and direct input\nand output however you desire.\n\n### Example: One-step\n\n```bash\n$ psql dbname -qAtc 'EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) SELECT id FROM users' \\\n    | pg_flame \\\n    \u003e flamegraph.html \\\n    \u0026\u0026 open flamegraph.html\n```\n\n### Example: Multi-step with SQL file\n\nCreate a SQL file with the `EXPLAIN ANALYZE` query.\n\n```sql\n-- query.sql\nEXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)\nSELECT id\nFROM users\n```\n\nThen run the query and save the JSON to a file.\n\n```bash\n$ psql dbname -qAtf query.sql \u003e plan.json\n```\n\nFinally, generate the flamegraph HTML.\n\n```\n$ cat plan.json | pg_flame \u003e flamegraph.html\n```\n\n### Example: Docker\n\nIf you've followed the Docker installation steps above, you can pipe query plan\nJSON to a container and save the output HTML.\n\n```\n$ psql dbname -qAtc 'EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) SELECT id FROM users' \\\n    | docker run -i pg_flame \\\n    \u003e flamegraph.html\n```\n\n## Background\n\n[Flamegraphs](http://www.brendangregg.com/flamegraphs.html) were invented by\nBrendan Gregg to visualize CPU consumption per code-path of profiled software.\nThey are useful visualization tools in many types of performance\ninvestigations. Flamegraphs have been used to visualize Oracle database\n[query\nplans](https://blog.tanelpoder.com/posts/visualizing-sql-plan-execution-time-with-flamegraphs/)\nand [query\nexecutions](https://externaltable.blogspot.com/2014/05/flame-graphs-for-oracle.html)\n, proving useful for debugging slow database queries.\n\nPg_flame is in extension of that work for Postgres query plans. It generates a\nvisual hierarchy of query plans. This visualization identifies the relative\ntime of each part of a query plan.\n\nThis tool relies on the\n[`spiermar/d3-flame-graph`](https://github.com/spiermar/d3-flame-graph) plugin to\ngenerate the flamegraph.\n","funding_links":[],"categories":["Go","Management Utilities","postgresql","Compiled list","Optimization","SQL"],"sub_categories":["plv8:","Plan"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgartner%2Fpg_flame","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgartner%2Fpg_flame","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgartner%2Fpg_flame/lists"}