Pull to refresh

All streams

Show first
Period
Level of difficulty

PostgreSQL cost model: estimating the cost of flushing temp buffers to disk

Level of difficultyMedium
Reading time8 min
Reach and readers1.2K

Today I present results from the first step towards enabling temporary tables in PostgreSQL parallel query execution: benchmarking sequential writes and reads of temp buffers. I added functions to the PostgreSQL system catalog to measure buffer flush operations and ran a set of tests. For the planner, I estimated the cost coefficient of flushing a temporary table buffer page to disk relative to the existing DEFAULT_SEQ_PAGE_COST. I also estimated the cost of a simple scan of temp buffers (a dry-run). Measurements show that sequential writes are about 30% slower than reads. Based on these results, I propose a cost formula. I also ran a limited “dry-run” style estimate and measured write speed when table blocks are distributed across memory pages randomly.

Read more