PlannerAny session (SET)default 4

random_page_cost

Sets the planner's estimate of the cost of a nonsequentially fetched disk page.

How you change it

Any session (SET)

Defaults and ranges on this page were read from pg_settings on live PostgreSQL 18.4. Treat older majors as needing their own check before you copy a value.

What this means

The planner's estimated cost of a non-sequential (random) page fetch, relative to seq_page_cost which is 1.0. The default of 4.0 models a spinning disk where random reads are several times costlier than sequential ones. Lowering it makes the planner more willing to choose index scans.

When it matters

Lower toward 1.1-2.0 on SSD/NVMe storage, where random reads are nearly as cheap as sequential.

Default4
Range0 – 1.79769e+308
Typereal
Change scopeAny session (SET)
CategoryPlanner
Check the current value
SHOW random_page_cost;

Tradeoffs

  • Too high on SSDs: the planner avoids index scans it should be using.
  • Too low: the planner may choose index scans that are actually slower than a sequential scan.
  • Tune alongside effective_cache_size; both shape scan-vs-index decisions.

Workload profiles

SSD / NVMe

Try 1.1 to 2.0.

Random reads are close to sequential on flash.

Spinning disk

Leave near the 4.0 default.

Seeks genuinely cost more on rotational media.

PostgreSQL manual: random_page_cost

← All GUCs · Glossary · Runbooks