Skip to content
Tomas Vondra·

🔍PostgreSQL Random_Page_Cost Defaults Under Scrutiny

PostgreSQL's random_page_cost is getting a rethink

TL;DR

PostgreSQL's random_page_cost defaults are being questioned, with the default of 4.0 not accurately reflecting real-world I/O costs. This impacts query planning and performance tuning.

PostgreSQL's default random_page_cost of 4.0 is being reevaluated, as it doesn't accurately represent the cost of random I/O on modern storage. This impacts query planning and performance tuning, pushing the planner towards inefficient plans. The estimated random_page_cost for SATA drives is 125, compared to 2-4 times less for SSDs. This change affects how developers tune their PostgreSQL databases for optimal performance. The cost model ignores memory and has a safety limit called work_mem, which limits work buffer sizes. Tuning must be system-specific and driven by monitoring feedback.

Key Points

1

Default random_page_cost is 4.0, but SATA drives cost 125, SSDs 2-4 times less.

2

Increasing random_page_cost doesn't improve performance, it hurts it.

3

Cost model ignores memory and has a safety limit called work_mem.

4

Sequential scans push data from memory, while index scans access less data.

5

Tuning random_page_cost must be system-specific and driven by monitoring.

Why It Matters

If you're tuning PostgreSQL for performance, the default random_page_cost of 4.0 is misleading. SATA drives cost 125, SSDs 2-4 times less. This impacts query planning and performance tuning, pushing the planner towards inefficient plans. Developers must tune random_page_cost system-specifically based on monitoring feedback.

PostgreSQLrandom_page_costperformance-tuningquery-planningdatabase-optimization

Frequently Asked Questions

Why does this matter?

If you're tuning PostgreSQL for performance, the default random_page_cost of 4.0 is misleading. SATA drives cost 125, SSDs 2-4 times less. This impacts query planning and performance tuning, pushing the planner towards inefficient plans. Developers must tune random_page_cost system-specifically based on monitoring feedback.

What happened?

PostgreSQL's random_page_cost defaults are being questioned, with the default of 4.0 not accurately reflecting real-world I/O costs. This impacts query planning and performance tuning.

Comments

Subscribe to join the conversation...

Be the first to comment

Enjoyed this article?

Get it daily. 7am. Free. Reads in 5 minutes.

Join 3,464 builders reading daily.

Also get