Finding the execution plan

Now, we know that the planner has quite a few decisions to make and that these decisions will ultimately decide the execution time as well as consumption of resources (CPU, memory, and disk I/O). How do we know what decision the planner will take? We can use the EXPLAIN command to find out the possible (note that it's possible) execution plan. To use EXPLAIN, we have to just prefix the EXPLAIN word to the SQL statement we want to execute, as shown here:

EXPLAIN SELECT first_name FROM customer_master WHERE first_name = 'Carolee'; QUERY PLAN ----------------------------------------------------------------- Seq Scan on customer_master (cost=0.00..271.62 rows=3 width=6) Filter: ((first_name)::text = 'Carolee'::text) (2 rows) ...

Get PostgreSQL for Data Architects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.