]> granicus.if.org Git - postgresql/commit
Make large sequential scans and VACUUMs work in a limited-size "ring" of
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 30 May 2007 20:12:03 +0000 (20:12 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 30 May 2007 20:12:03 +0000 (20:12 +0000)
commitd526575f893c1a4e05ebd307e80203536b213a6d
tree529be7e5571f622bad1daab0d02de0c6669e9b81
parent0a6f2ee84de589e14941da640fb686c7eda7be01
Make large sequential scans and VACUUMs work in a limited-size "ring" of
buffers, rather than blowing out the whole shared-buffer arena.  Aside from
avoiding cache spoliation, this fixes the problem that VACUUM formerly tended
to cause a WAL flush for every page it modified, because we had it hacked to
use only a single buffer.  Those flushes will now occur only once per
ring-ful.  The exact ring size, and the threshold for seqscans to switch into
the ring usage pattern, remain under debate; but the infrastructure seems
done.  The key bit of infrastructure is a new optional BufferAccessStrategy
object that can be passed to ReadBuffer operations; this replaces the former
StrategyHintVacuum API.

This patch also changes the buffer usage-count methodology a bit: we now
advance usage_count when first pinning a buffer, rather than when last
unpinning it.  To preserve the behavior that a buffer's lifetime starts to
decrease when it's released, the clock sweep code is modified to not decrement
usage_count of pinned buffers.

Work not done in this commit: teach GiST and GIN indexes to use the vacuum
BufferAccessStrategy for vacuum-driven fetches.

Original patch by Simon, reworked by Heikki and again by Tom.
24 files changed:
src/backend/access/hash/hash.c
src/backend/access/hash/hashovfl.c
src/backend/access/hash/hashpage.c
src/backend/access/heap/heapam.c
src/backend/access/nbtree/nbtree.c
src/backend/access/transam/xlog.c
src/backend/catalog/index.c
src/backend/commands/analyze.c
src/backend/commands/vacuum.c
src/backend/commands/vacuumlazy.c
src/backend/postmaster/autovacuum.c
src/backend/storage/buffer/README
src/backend/storage/buffer/bufmgr.c
src/backend/storage/buffer/freelist.c
src/backend/storage/buffer/localbuf.c
src/backend/tcop/utility.c
src/include/access/genam.h
src/include/access/hash.h
src/include/access/relscan.h
src/include/access/xlog.h
src/include/commands/vacuum.h
src/include/storage/buf.h
src/include/storage/buf_internals.h
src/include/storage/bufmgr.h