select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

CONFIGURATION / QUERY TUNING

cpu_operator_cost

Read PG 18 manual ↗

Sets the planner's estimate of the cost of processing each operator or function executed during a query.

Type
real
Context
user
Measured default
0.0025
Unit
Metadata snapshot
18

Definition PG 18 manual

Sets the planner's estimate of the cost of processing each operator or function executed during a query. The default is 0.0025.

Measured default history
Version intervalDefault
9.0 – 190.0025
Analysis & operational context

Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗

How it works

cpu_operator_cost models the CPU work for each operator or function invocation. It is one term in estimated path cost and does not allocate resources or change executor behavior directly.

Planner cost units are arbitrary and only their ratios matter. Scaling all cost constants together leaves path ordering unchanged; changing one alters the balance between I/O, row processing, operators, and parallel overhead.

The value is consulted when a plan is built. Statistics, row-count estimates, cache assumptions, tablespace overrides, and enabled plan methods can outweigh a small change in this constant. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value.

Operational considerations

Interpreting the value as elapsed time or a hard resource limit.

Tuning it to repair one query and regressing the wider workload.

Changing cost constants before correcting statistics and cardinality estimates.

Forgetting that only relative values influence path choice.

Workload guidance

OLAP: Analytical workloads can justify a different CPU-versus-I/O balance, but change cpu_operator_cost together with the related cost model and validate the full scan/join/aggregate mix.

OLTP: Calibrate cpu_operator_cost only from a representative workload, not one plan. First correct stale statistics and compare EXPLAIN (ANALYZE, BUFFERS) estimates with reality; use role or tablespace scope where possible.

SMALL: Keep the upstream value unless repeated evidence shows a systematic modeling error. On small systems, concurrency and cache residency often matter more than fine-grained changes to cpu_operator_cost.

Related entries

Further reading

Definition snapshot: english-manuals:d4dbd0ae06a4afb9a707471f7ce… · English manual source