Parameter · Query Tuning / Planner Cost Constants
cpu_operator_cost
Sets the planner's estimate of the cost of processing each operator or function call.
- Default:
0.0025 - Type: real
- Range: 0 … 1.79769e+308
- Applies: Session (any user)
In plain words
Each comparison like a = 5 or each function call costs some CPU. This is the planner's price for one such evaluation. Queries with many conditions or expensive expressions get more costly estimates as it rises.
For DBAs and operators
Every operator and function has a procost (in pg_proc, default 1 for C and internal functions, 100 for most others), and the planner charges procost × cpu_operator_cost per evaluation. That is why a WHERE clause with one comparison adds 0.0025 per row: 200,000 rows × 0.0025 = 500, turning a 4,273 Seq Scan into 4,773.
The same price is used for hashing and comparisons in sorts, hash joins and aggregates, and to decide the order in which WHERE conditions are evaluated (cheap ones first). Declaring the real cost of an expensive user function with ALTER FUNCTION … COST 1000 is usually more useful than changing this global constant. It also matters for JIT: jit_above_cost thresholds are reached sooner by queries with many expressions.
How to change it
Any user can change it for their session with SET.