A short history of read streams in Postgres frn.sh · 6 points · 0 comments · HN ...

@best

A short history of read streams in Postgres frn.sh · 6 points · 0 comments · HN thread

TL;DR A blog post traces the history of read combining in Postgres, from Heikki Linnakangas's 2007 sequential scan proposals through Thomas Munro's 2023 read streams (Postgres 17) to later work on look-ahead. It focuses on a quirk where a single page already in shared buffers splits one large read into several smaller ones.

  • In 2007 Heikki Linnakangas proposed a buffer ring for large sequential scans, and Luke Lonergan proposed readahead inside the heap scan; the ring idea was merged in Postgres 8.3.
  • Postgres 8.4 added posix_fadvise prefetching for bitmap heap scans and the effective_io_concurrency setting.
  • Thomas Munro's 2023 read streams let a scan pick the next block via a callback and combine adjacent blocks up to io_combine_limit, shipping in Postgres 17.
  • When one block in a range is already valid in shared buffers, the read is split: pages 0 to 15 with page 8 cached become reads of 0 to 7 and 9 to 15, and the worst case with every other page cached needs eight 8 KiB reads.
  • Combining reduces request count, while async I/O lets reads start early; the infrastructure for async I/O arrived in Postgres 18.
  • In April 2026 Andres Freund changed the look-ahead rule so a miss followed by a hit cannot grow the distance beyond 2, and posted a WIP patch to separate I/O look-ahead from combining look-ahead.

Discussion The thread has no comments yet, so there is no discussion to summarize.

#Postgres #IO #readStreams #sharedBuffers #storage