CertGrid CertGrid
Hands-on Lab·PostgreSQL

PostgreSQL Query Plans with EXPLAIN

`EXPLAIN (ANALYZE, BUFFERS)` gives estimates, actuals and the number that matters most - how many pages were touched. Adding one index takes a query from 4,546 buffers and two parallel workers to 21 buffers and none.

Performance Guide 33 of 47 Intermediate

Written against the versions above. `BUFFERS` is on by default with `ANALYZE` from PostgreSQL 18. On earlier versions you must ask for it, and it is the option most worth asking for.

Every command on this page ran on db-a01.
Server NameIP AddressOSRolesCPURAMHDD
db-a01192.168.0.81Ubuntu 26.04 LTSPrimary / Source / Replica Set Member 12 Core4 GB50 GB

Before you start

  1. Build a table worth planning against

  2. Read a plan with no index

  3. Add the index and compare

  4. Filter on the second column only

Official sources