This article challenges the common practice of lowering random_page_cost for SSDs in PostgreSQL, demonstrating through experiments that the actual cost ratio of random to sequential reads is often much higher than the default value. It explores how inaccurate cost parameters can lead the query planner to choose inefficient execution plans and discusses the complex relationship between prefetching and I/O costs.
在自動化調優方面,社群提出了具備前瞻性的構想。有觀點認為,手動管理這些參數過於繁瑣,或許可以透過代理層(如 ProxySQL)或側車程序(Sidecar)來動態監控查詢效能。這種做法能藉由分析 Prometheus 統計數據或定期執行 EXPLAIN ANALYZE,針對特定查詢自動附加 SET LOCAL 指令來調整參數。這種「查詢重寫」的思路,試圖在不更動全域配置的情況下,解決規劃器在特定選擇度下選錯計畫的問題。