Query Tuning with Explain

EXPLAIN(FORMAT JSON)
SELECT * 
FROM public.test
WHERE hello IN (SELECT hello FROM public.test ORDER BY hello DESC LIMIT 1);

query plan

Using EXPLAIN(ANALYZE) and then pasting the output of the plan into this tool gives like a flame graph:

https://explain.depesz.com/

flame graph

This tool is also amazing for displaying graphics on a plan

https://explain.dalibo.com/

query plan

Setting EXPLAIN to be done automatically (must be a super user to load the module)

LOAD 'auto_explain';

Explain will just provide the plan calculations

Running Analyze as well will actually execute the statement so if running on a DELETE statement be careful if just testing


Backlinks