Configuration parameter

random_page_cost — PostgreSQL Configuration Parameter

Category Query Planner Default 4.0 Unit boolean / enum / numeric Change scope Per-session (SET)

Planner cost of a non-sequential page fetch.

At a glance

Property Value
Parameter random_page_cost
Category Query Planner
Default 4.0
Value type boolean / enum / numeric
Change scope Per-session (SET)

What it does

The estimated cost of fetching a randomly-accessed disk page, relative to seq_page_cost (1.0). High values discourage index scans.

How to apply a change

Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.

Inspect the current value and source with SHOW random_page_cost; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'random_page_cost';.

Tuning guidance

Lower to 1.1-1.5 on SSD/NVMe or well-cached databases — the default 4.0 assumes spinning disks and often wrongly favors sequential scans on modern storage.

Reference

PostgreSQL documentation — Query Planner configuration.

Was this helpful?

← All configuration parameters