postgres=# select * from sessions where video_id = 'D1PEdDcvZTw';

Index bloat and B-tree page merge, part 1

· 84:02 · Storage internals

Merge sparse sibling B-tree pages to reduce bloat.

session summary

This B-tree page-merge session moved from automated REINDEX toward fixing the cause of persistent bloat. The group defined the target as partially empty leaf pages that vacuum cannot reclaim, then had an agent build a logical leaf-page scan that reports adjacent pages fitting into one block. On a randomized 90%-deleted workload it found widespread merge opportunities. They did not implement merging: backward-scan visibility, transaction horizons, WAL replay, lock coupling, and undetectable lightweight-lock deadlocks were identified as the core design problems.

timecodes

  1. From automated REINDEX to B-tree page merge
  2. Defining the persistent bloat worth fixing
  3. Planning a logical scan for merge candidates
  4. Agent-assisted prototype of the merge checker
  5. Correcting physical scan to logical leaf order
  6. The logical adjacency scanner works
  7. Randomized deletion reveals widespread candidates
  8. Backward scans, WAL, and lock-coupling hazards