Truncate line pointer array during heap pruning.
authorPeter Geoghegan <pg@bowt.ie>
Thu, 7 Apr 2022 22:42:12 +0000 (15:42 -0700)
committerPeter Geoghegan <pg@bowt.ie>
Thu, 7 Apr 2022 22:42:12 +0000 (15:42 -0700)
commit10a8d138235b3b8cfbce8a0145526d9b9a80cc96
tree30b4fee62e88402c1f5587a1054951f859a72e1e
parent9d9c02ccd1aea8e9131d8f4edb21bf1687e40782
Truncate line pointer array during heap pruning.

Reclaim space from the line pointer array when heap pruning leaves
behind a contiguous group of LP_UNUSED items at the end of the array.
This happens during subsequent page defragmentation.  Certain kinds of
heap line pointer bloat are ameliorated by this new optimization.

Follow-up work to commit 3c3b8a4b26, which taught VACUUM to truncate the
line pointer array in about the same way during VACUUM's second pass
over the heap.  We now apply line pointer array truncation during both
the first and the second pass over the heap made by VACUUM.  We can also
perform line pointer array truncation during opportunistic pruning.

Matthias van de Meent, with small tweaks by me.

Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://postgr.es/m/CAEze2WjgaQc55Y5f5CQd3L=eS5CZcff2Obxp=O6pto8-f0hC4w@mail.gmail.com
Discussion: https://postgr.es/m/CAEze2Wg36%2B4at2eWJNcYNiW2FJmht34x3YeX54ctUSs7kKoNcA%40mail.gmail.com
src/backend/access/heap/pruneheap.c
src/backend/access/heap/vacuumlazy.c
src/backend/storage/page/bufpage.c