# Explaining your PostgreSQL data

DevFeed: [Explaining your PostgreSQL data](<https://devfeed.tech/articles/explaining-your-postgresql-data-41142.md>)

Original publisher: [Read original article](<https://www.craigkerstiens.com/2013/06/13/Explaining-your-PostgreSQL-data/>)

Author: Map

Published: 2013-06-13T20:55:56Z

Content type: tutorial

Language: en

Sources: [Craig Kerstiens](<https://devfeed.tech/sources/craig-kerstiens.md>)

Topics: [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [JSON](<https://devfeed.tech/topics/json.md>), [execution](<https://devfeed.tech/topics/execution.md>)

Tags: [execution](<https://devfeed.tech/tags/execution.md>), [json](<https://devfeed.tech/tags/json.md>), [postgres](<https://devfeed.tech/tags/postgres.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [query](<https://devfeed.tech/tags/query.md>), [sql](<https://devfeed.tech/tags/sql.md>)

## AI overview

This tutorial explains how to understand PostgreSQL execution plans and retrieve EXPLAIN or EXPLAIN ANALYZE output in JSON format. It also highlights Dezpez's explain tool for visualizing and sharing execution plans.

## Source excerpt

I've written a bit before about understanding the output from EXPLAIN and EXPLAIN ANALYZE in PostgreSQL. Though understandably getting a grasp on execution plans could probably use some more guidance. Yet, this time around I'm taking a bit of a cop out and highlighting a few tools instead of documenting myself, which I've done in a talk I've frequently given Postgres Demystified. Getting at the Data The first small thing you can do is actually retrieve the data in JSON form. By adding in (format json) right after your EXPLAIN or EXPLAIN ANALYZE command it'll as you'd expect return it in JSON. To give an example: # EXPLAIN SELECT * FROM users LIMIT 1; QUERY PLAN -------------------------------------------------------------- Limit (cost=0.00..0.03 rows=1 width=812) -> Seq Scan on users (cost=0.00..1.50 rows=50 width=812) (2 rows) Then in JSON format: EXPLAIN (format json) SELECT * FROM users LIMIT 1; QUERY PLAN ------------------------------------------------ [ + { + "Plan": { + "Node Type": "Limit", + "Startup Cost": 0.00, + "Total Cost": 0.03, + "Plan Rows": 1, + "Plan Width": 812, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer",+ "Relation Name": "users", + "Alias": "users", + "Startup Cost": 0.00, + "Total Cost": 1.50, + "Plan Rows": 50, + "Plan Width": 812 + } + ] + } + } + ] (1 row) While its on my list to build some interesting apps by pulling in the JSON input, others may be equally as interested in taking advantage of this data in its JSON form. If you take a shot at building something with this output, as always I'd love to hear about it - craig.kerstiens@gmail.com Despez Of course if you're itch isn't in better tools for Postgres, you may just want to have a solution that works today. While its not perfect, one of the best ones out there is Dezpez's explain tool. You can take any execution plan and paste it in and get some better visual representation of the result. You can also share them as well.