Skip to content

Using PostgreSQL Explain Graph

William Meitzen edited this page Dec 18, 2019 · 35 revisions

Need help? Have a suggestion? Navigate to Issues.
Read about the latest updates.
Dive into Advanced Features of PostgreSQL Explain Graph.

Click images below to see them full-size.

Tested for all versions of PostgreSQL from 9.3 - 12.1. Free... for now.

Step 1 / Enter your credentials and query OR Paste JSON plan

Enter your server hostname, database, userid, password, etc. and query.

OR

If you've already generated a JSON plan(from psql, your database application, or wherever it is), plan, copy it and paste it into the bottom field.

Your query MUST include explain and format json. PostgreSQL Explain Graph will not be able to show the plan without these parameters.

For default installations of PostgreSQL, explain (analyze, buffers, format json, verbose) select ... will execute the query and retrieve all possible information.

You may include any other explain options you wish (analyze, buffers, costs, settings, summary, timing, verbose). If you run the actual query (by specifying analyze), it may take a little longer, but you will get far more useful information. Specifying explain (format json) select ... will retrieve the plan soonest because it won't execute the query.

Step 2 / Wait A Moment

Wait for your PostgreSQL database to retrieve the plan details.

Once the JSON plan is retrieved, it will be stored in the JSON plan field. This way, you can study it in the future or send it to others for analysis without running the query again.

If you paste only a JSON explain plan, then click ##Show JSON Plan Graph##, it should appear quickly.

Step 3 / Browse Your Plan Graph!

Click operators to see their properties.

Use the toolbar to view actual or estimated rows or data mass, and show the ratios between actual and estimated values. Red and yellow backgrounds indicate largest and second largest percentages. On each arrow, boldface text indicates actual values, and normal text indicates estimates. If there are no numbers, it means there are no values, or you are viewing a ratio.

Use the time slider and cost slider to get a sense of how long each operation takes in relation to other operations, as well as the entire query.

If an operator has a little box in the upper-right corner, that means the operation is using workers. Click the little box to toggle worker information.

After you generate two or more explain plan graphs, you can compare their costs and duration. Highlight all plans you want to compare, then click the Compare Plans tab.

Clone this wiki locally