30

PostgreSQL EXPLAIN glossary

 4 years ago
source link: https://www.pgmustard.com/docs/explain
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

EXPLAIN is the command used to request the execution plan for a query. It is incredibly useful when you want to explore what is going on, and see if there could be a more efficient way.

PostgreSQL does an amazing job populating query plans with useful information, but reading and understanding them can be tricky.

Here is a simple example:

Query
----------
explain select * from t order by c;

Query plan
----------
 Sort  (cost=813.32..837.48 rows=9664 width=32)
   Sort Key: c
   ->  Seq Scan on t  (cost=0.00..173.64 rows=9664 width=32)

This tells us that Postgres would do a sequential scan of our table “t”, then a sort by column “c”. The numbers tell us the startup cost , the total cost , the plan rows , and the plan width at each stage.

We have documented many of the operations and field definitions you’re likely to come across while using EXPLAIN, along with performance advice and links to further learning resources.

For advice in the context of your query plans, check out our product pgMustard .

Last updated: June 2020, PostgreSQL 12

Issue reports and suggestions are welcome, please get in touch .


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK