Do not emit WAL record for FSM truncaton when unneeded.

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Do not emit WAL record for FSM truncaton when unneeded.
Date: 2025-11-22 06:12:05
Message-ID: CALdSSPhhWpufHQAFT8bZXR_qQNmYNDEVUfJtKYXSNSUDOyeCgw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers!

While working on other matters, I noticed that the
`fsm_truncate_avail` function returns a bool parameter which is never
used. This makes me think we can make an enhancement here. There are
basically two options:
1) make return type `void`
2) make use of return value.

I tried the second option. In FreeSpaceMapPrepareTruncateRel (the only
user of fsm_truncate_avail), we call fsm_truncate_avail and then
WAL-log FSM page changes.
Instead, can use `fsm_truncate_avail ` return value to check if
WAL-logging can be skipped.
PFA with these changes.

Thoughts?

P.S. I did not make a POC of real-life scenarios when the FSM page is
unaltered by fsm_truncate_avail (yet). I wonder if there are such
scenarios. If there is none, option 1 should proceed IMHO.

--
Best regards,
Kirill Reshke

Attachment Content-Type Size
v1-0001-Do-not-emit-WAL-record-for-FSM-truncaton-when-unn.patch application/octet-stream 2.2 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Nazir Bilal Yavuz 2025-11-22 08:09:30 Re: meson and check-tests
Previous Message Nico Williams 2025-11-22 05:24:11 Re: [oauth] SASL mechanisms