pgsql: Reduce WAL generated when copying relation storage

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Reduce WAL generated when copying relation storage
Date: 2026-11-20 20:43:38
Message-ID: E1xUVSL-00000000Ycd-2hrG@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Reduce WAL generated when copying relation storage

RelationCopyStorage() treated every page as nonstandard, logging the
region between pd_lower and pd_upper in full-page images even when it
was known to be free space.

Apply the same policy that db26517e79c established for
RelationCopyStorageUsingBuffer(): omit that region for heap and B-tree
main-fork pages, which are known to use the standard page layout. For
other pages, omit it only if the bounds are valid and the region
contains only zeroes. This reduces WAL volume without losing data on
pages with nonstandard layouts.

Author: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Reviewed-by: surya poondla <suryapoondla4(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAAKRu_b9r-Pz9gzYvC%2B5EHnXqNgfsJhcH%3DhuUGbXzvcnbHtxCg%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ecb260853526019a1340ba8a6b4c6de27a07d69b

Modified Files
--------------
src/backend/access/heap/heapam_handler.c | 11 ++++++++---
src/backend/catalog/storage.c | 20 +++++++++++++++-----
src/backend/commands/tablecmds.c | 11 ++++++++---
src/include/catalog/storage.h | 3 ++-
src/test/recovery/t/018_wal_optimize.pl | 13 +++++++++++++
5 files changed, 46 insertions(+), 12 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-11-20 21:04:32 pgsql: Fix long description of extension_control_path
Previous Message Tom Lane 2026-11-20 19:53:16 pgsql: Fix SEARCH/CYCLE when the recursive term is SELECT DISTINCT.