O'Reilly logo

PostgreSQL High Performance Cookbook by Dinesh Kumar, Chitij Chauhan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Query plan node structure

In this recipe, we will be discussing the explain plan tree structure.

Getting ready

PostgreSQL generates a set of plans before choosing an optimal plan that it is going to execute, based on the collected statistics about the relations. That is, the plan we are going to get when we use the EXPLAIN command along with the SQL statement is the optimal plan for that query. We also used EXPLAIN statements extensively on previous topics, and now we are going to understand the plan structure, and the significance of each value in it.

How to do it…

Let's run a basic EXPLAIN query and evaluate it as follows:

benchmarksql=# EXPLAIN SELECT * FROM bmsql_customer WHERE c_id=0;                                                                                      
                                           QUERY PLAN                                           
------------------------------------------------------------------------------------------------ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required