# random_page_cost

> A planner cost constant describing non-sequential page access relative to sequential access. Lowering it makes index and bitmap access paths look cheaper; it does not change storage behavior itself.
---

> [!NOTE]
> **Fact — official short description:** “Sets the planner's estimate of the cost of a nonsequentially fetched disk page.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `real` | Upstream pg_settings type |
| Context | `user` | Settable by an ordinary user |
| Unit | — | Raw unit |
| Range | `0` – `1.79769e+308` | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Query Tuning / Planner Cost Constants | Upstream classification |
| Latest boot value | `4` | 4 |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG9.0 (research boundary) |
| Present in | PG9.0–19 Beta 3 |
| Removed in | No |
| Introduction commit | Not asserted: predates the PG9.0 research boundary |
| Commit date | — |
| Discussion | — |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG9.0–19 Beta 3 | `4` | — | 4 |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

Planner cost units are arbitrary and meaningful mainly in relation to other cost constants. With seq_page_cost conventionally at 1.0, random_page_cost expresses the average penalty of random page access after accounting for expected caching and storage behavior.

Reducing the value relative to seq_page_cost favors index scans; increasing it makes such scans less attractive. Both values can also be overridden per tablespace, which is useful when a cluster spans storage tiers.

The official guidance treats these constants as workload-wide averages and warns against changing them from a few isolated experiments. Plan quality also depends on statistics, effective_cache_size, correlation, and query shape.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| OLTP | On low-latency SSD with a high cache hit rate, 1.1 is a reasonable trial value, not a universal truth. Compare representative EXPLAIN (ANALYZE, BUFFERS) plans and tail latency before adopting it. |
| OLAP | Do not lower it merely because storage is SSD; analytical scans may still favor sequential access. Calibrate with the full scan-versus-index workload mix and consider tablespace-specific values. |
| Small nodes | If the entire database is usually cached, a value near seq_page_cost can be defensible. Avoid setting it below seq_page_cost and fix stale statistics before forcing index-heavy plans. |
{.full-width}

## Pigsty {#pigsty}

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

| Template | Effective value | Versus upstream boot | Source expression |
| --- | --- | --- | --- |
| OLTP | `1.1` | different | `1.1` |
| OLAP | `1.1` | different | `1.1` |
| CRIT | `1.1` | different | `1.1` |
| TINY | `1.1` | different | `1.1` |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 = 1.1 (dcs); OLAP: PG9.0–19 Beta 3 = 1.1 (dcs); CRIT: PG9.0–19 Beta 3 = 1.1 (dcs); TINY: PG9.0–19 Beta 3 = 1.1 (dcs). Advice, pending human review — Editorial hypothesis, pending maintainer review: 1.1 models SSD random access and cache-heavy deployments as much closer to sequential access.

## Common pitfalls {#common-pitfalls}

- The number is a relative planner cost, not milliseconds or measured device latency.
- Lowering it to repair one query can regress the wider workload.
- Bad cardinality estimates can be mistaken for incorrect storage costs.
- A value below seq_page_cost is normally physically implausible.
- A global value can misrepresent mixed SSD, HDD, and network-attached tablespaces.

## Related parameters {#related-parameters}

[`seq_page_cost`](/parameters/seq-page-cost/) · [`effective_cache_size`](/parameters/effective-cache-size/) · [`effective_io_concurrency`](/parameters/effective-io-concurrency/) · [`default_statistics_target`](/parameters/default-statistics-target/) · [`enable_indexscan`](/parameters/enable-indexscan/) · [`enable_bitmapscan`](/parameters/enable-bitmapscan/)

## References {#references}

- [PostgreSQL 19 Beta 3 — random_page_cost](https://www.postgresql.org/docs/19/runtime-config-query.html#GUC-RANDOM-PAGE-COST)
- [PostgreSQL 18: Using EXPLAIN](https://www.postgresql.org/docs/18/using-explain.html)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
