Goal: compare current heap occupancy with historical hit counters and test a larger cache.
The provided tables have 5,000 small rows and 60,000 wide rows; setup installed pg_buffercache, disabled fixture autovacuum, and restarted with an 8-MB shared cache. Read heap sizes and cache capacity. The large heap exceeds the initial cache and remains over one quarter of the later 32-MB cache. block_size is read from the server rather than assuming 8,192 bytes. This controlled serial workload is not a cache-sizing recommendation.
All hints run at the Linux shell. psql -c executes quoted SQL and exits; each command uses a new connection. -U postgres explicitly selects the administrative SQL role, and -v ON_ERROR_STOP=1 stops on SQL errors. The monitoring tables are separate provided fixtures, not the baked business datasets.
Goal: make sure the experiment touches heap pages rather than only a primary-key index.
COUNT(*) can use an index-only scan, so use sums that require the non-indexed data. Inspect the plans for sequential scans, then expect 12,502,500 for the small sum and 12,000,000 total payload bytes for the large table. These are logical payload totals, not file sizes or disk-read bytes.
Goal: measure the two heaps in the shared cache with a correct relation identity.
Match database, tablespace, filenode, and fork: a filenode alone can match pages from another database. Fork 0 is the main heap; index and auxiliary-map buffers are excluded. LEFT JOIN keeps a table with zero resident pages visible, while count(bufferid) counts occupied matches. Expect some but not all large-heap blocks cached. Buffer rows can change while inspected; the view is not one atomic snapshot of the whole cache.
Goal: explain why historical hits and current occupancy answer different questions.
Read hits/reads and their percentage for the qualified fixture relations. These counters include prior activity and survive a clean restart, whereas the shared-buffer contents do not. A read means a shared-cache miss and may still hit the OS cache. A high historical hit percentage would not prove full current residency.
Goal: apply a 32-MB shared cache and verify the active value.
shared_buffers needs a restart. The cache becomes larger than the large heap, but the heap still qualifies for the large-scan buffer strategy. A restart discards old buffer residency; it does not guarantee the next scan fills the cache or improves performance.
Goal: separate the restart’s empty cache from the subsequent heap scan.
Inspect before reading: both main heaps should have zero buffers in this controlled start. Then rerun the same sums. This baseline matters because inserts and earlier scans can leave pages warm. The data remains 5,000 and 60,000 rows; capacity changed, not the workload.
Goal: observe a large scan’s bounded cache strategy despite the larger capacity.
Read the correctly attributed buffers again, then the client-backend bulkread context in pg_stat_io. Expect a partly resident large heap and positive bulk-read activity. Ring strategies limit disruption from large one-off scans; they do not promise a fixed buffer count or forbid a relation being fully cached by another workload. Repeated indexed access or explicit prewarming are reference topics here, not tested solutions.