PostgreSQL's planner uses three CPU cost constants — cpu_tuple_cost (0.01), cpu_index_tuple_cost (0.005), and cpu_operator_cost (0.0025) — as relative weights anchored to seq_page_cost. These defaults encode stable CPU-to-storage ratios that have held for 25 years and should almost never be changed. When a query plan is wrong, the real culprits are almost always random_page_cost (especially on SSDs, where lowering it toward 1.1 is appropriate) or inaccurate row-count estimates (fixable via ANALYZE and statistics tuning). Changing the CPU constants is a global operation that silently re-prices every plan on the system, likely fixing one query while breaking others.

4m read timeFrom postgr.es
Post cover image
5.7K Impressions