Truncate line pointer array during VACUUM.
commit3c3b8a4b26891892bccf3d220580a7f413c0b9ca
authorPeter Geoghegan <pg@bowt.ie>
Wed, 7 Apr 2021 15:47:15 +0000 (7 08:47 -0700)
committerPeter Geoghegan <pg@bowt.ie>
Wed, 7 Apr 2021 15:47:15 +0000 (7 08:47 -0700)
tree1f734ebb5c56cf901065e7b55bcc2033325b1d73
parent3db826bd55cd1df0dd8c3d811f8e5b936d7ba1e4
Truncate line pointer array during VACUUM.

Teach VACUUM to truncate the line pointer array of each heap page when a
contiguous group of LP_UNUSED line pointers appear at the end of the
array -- these unused and unreferenced items are excluded.  This process
occurs during VACUUM's second pass over the heap, right after LP_DEAD
line pointers on the page (those encountered/pruned during the first
pass) are marked LP_UNUSED.

Truncation avoids line pointer bloat with certain workloads,
particularly those involving continual range DELETEs and bulk INSERTs
against the same table.

Also harden heapam code to check for an out-of-range page offset number
in places where we weren't already doing so.

Author: Matthias van de Meent <boekewurm+postgres@gmail.com>
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-By: Peter Geoghegan <pg@bowt.ie>
Discussion: https://postgr.es/m/CAEze2WjgaQc55Y5f5CQd3L=eS5CZcff2Obxp=O6pto8-f0hC4w@mail.gmail.com
Discussion: https://postgr.es/m/CAH2-Wzn6a64PJM1Ggzm=uvx2otsopJMhFQj_g1rAj4GWr3ZSzw@mail.gmail.com
src/backend/access/heap/heapam.c
src/backend/access/heap/pruneheap.c
src/backend/access/heap/vacuumlazy.c
src/backend/storage/page/bufpage.c
src/include/storage/bufpage.h