The idea · Lab 3.4.3PostgreSQL never updates a row in place: an UPDATE writes an entirely new row version and marks the old one dead, which normally means every index on the table needs a new entry pointing at that new version too — real WAL volume and real index growth, on every single update, regardless of whether the indexed columns themselves actually changed. A HOT (Heap-Only Tuple) update is the specific, valuable exception: when the new row version fits on the exact same heap page as the old one, and none of the table's indexed columns changed, PostgreSQL can skip writing any new index entries entirely, linking the old and new versions directly within the page instead.
The "fits on the same page" condition is where fillfactor comes in: a freshly loaded table at the default fillfactor of 100 packs every page essentially full, leaving no room for a new row version to land alongside the old one — every update is forced onto a different page, and HOT becomes structurally rare no matter how careful the application is. Lowering fillfactor deliberately reserves free space on each page at load time specifically so future updates have somewhere to land. This lab measures the real difference directly, and separately confirms the one condition under which HOT is impossible regardless of fillfactor: the updated column being indexed.
fillfactor=70, Measured
CREATE TABLE sql_hot_demo (id int PRIMARY KEY, counter int, indexed_val int, junk text) WITH (fillfactor=70);
CREATE INDEX ON sql_hot_demo(indexed_val);
INSERT INTO sql_hot_demo SELECT g, 0, g, repeat('a',50) FROM generate_series(1,5000) g;
UPDATE sql_hot_demo SET counter = counter + 1; -- x3 rounds, non-indexed column
SELECT n_tup_upd, n_tup_hot_upd, round(100.0*n_tup_hot_upd/n_tup_upd,1) AS pct_hot
FROM pg_stat_user_tables WHERE relname = 'sql_hot_demo';
n_tup_upd | n_tup_hot_upd | pct_hot
-----------+---------------+---------
15000 | 9468 | 63.1
With 30% of each page deliberately left empty at load time, 63.1% of updates to a non-indexed column found room to stay on the same page — a real, measured majority.
The Same 3 Rounds, at the Default fillfactor=100
CREATE TABLE sql_hot_default (id int PRIMARY KEY, counter int, junk text); -- fillfactor defaults to 100
-- identical 3 update rounds
n_tup_upd | n_tup_hot_upd | pct_hot
-----------+---------------+---------
15000 | 90 | 0.6
The identical update pattern, on a table packed to 100% at load time — only 0.6% HOT. With no reserved free space, almost every update is forced onto a different page, and HOT becomes structurally rare. fillfactor did not make HOT possible in principle; it made room for HOT to actually happen.
Updating the Indexed Column: Zero, Always
UPDATE sql_hot_demo SET indexed_val = indexed_val + 1000000;
SELECT n_tup_upd, n_tup_hot_upd, round(100.0*n_tup_hot_upd/n_tup_upd,1) AS pct_hot
FROM pg_stat_user_tables WHERE relname = 'sql_hot_demo';
n_tup_upd | n_tup_hot_upd | pct_hot
-----------+---------------+---------
20000 | 9468 | 47.3
n_tup_upd grew by 5,000 (this new round of updates), but n_tup_hot_upd stayed at exactly 9,468 — not one of these 5,000 updates was HOT, diluting the cumulative rate down from 63.1% to 47.3%. Changing an indexed column always requires a new index entry, regardless of how much free space the page has.
Key concepts
HOT (Heap-Only Tuple) update
An UPDATE where the new row version is written to the same heap page as the old version, and no indexed column changed value. PostgreSQL links the old and new versions directly within the page and skips writing any new index entries at all — real savings in both WAL volume and index growth, available only when both conditions hold simultaneously.
fillfactor
A per-table (or per-index) storage parameter controlling what percentage of each page PostgreSQL fills when initially writing data — the remainder is deliberately left empty. The default of 100 packs pages completely full, leaving no room for a HOT update's new row version to land nearby; a lower value (commonly 70-90 for heavily-updated tables) trades some extra disk space for headroom that keeps HOT updates possible for longer between VACUUMs.
What to remember
- A HOT update requires both conditions at once: the new row version fits on the same heap page, and no indexed column changed — meeting either condition alone is not enough
- fillfactor reserves free space on each page at load time specifically so future updates have room to stay HOT; the default of 100 leaves essentially none
- pg_stat_user_tables.n_tup_hot_upd against n_tup_upd is the direct, measurable way to check a table's real HOT rate, rather than assuming fillfactor alone guarantees one
- Free space is a consumable resource depleted by updates and reclaimed only by VACUUM — a sustained high HOT rate depends on autovacuum keeping up, not on fillfactor as a one-time allowance
- Updating an indexed column makes HOT impossible for that update, regardless of how much free space the page has — the real fix for a hot-path update touching an index is reconsidering the index itself