Skip to content

Instantly share code, notes, and snippets.

@marcomalva
Created April 21, 2023 03:20
Show Gist options
  • Save marcomalva/75c3967372a94cc4ae146afa135da1b6 to your computer and use it in GitHub Desktop.
Save marcomalva/75c3967372a94cc4ae146afa135da1b6 to your computer and use it in GitHub Desktop.
[Visualize PostgreSQL Query Plan Locally With Pev2] Basic Instructions #psql
-- https://github.com/dalibo/pev2
--
-- Save the query as an SQL file and paste the JSON file into the index.html
--
-- Download the index.html page with the command below and open it in your web browser:
-- wget https://www.github.com/dalibo/pev2/releases/latest/download/index.html
--
-- Obtain the database query plan with command below:
-- psql -h ${DB_HOST:-localhost} -p ${DB_PORT:-5432} -U ${DB_USER:-db_user} -XqAt -f "${filename}" > "analyze-${filename%.*}.json"
--
EXPLAIN (ANALYZE, COSTS, VERBOSE, BUFFERS, FORMAT JSON)
SELECT * FROM your_table;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment