Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w9kye-001iab-38 for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2026 14:30:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w9kyd-009D5G-1K for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Apr 2026 14:30:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w9kyd-009D58-0P for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2026 14:30:55 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w9kyb-00000000rie-0iZZ for pgsql-hackers@lists.postgresql.org; Mon, 06 Apr 2026 14:30:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1775485851; bh=NEAVWyKnIx4iIfaC5XH02W+4THb8lfJYQRxyCei1WMw=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=GeBlAQRj170BvHKSkl7e3f5WvS+036x+Wzqzgw5yUL0kxChsP36lkH/PtcClgqkNp UV89Zttvg8LZpKsErpYI4cMG1nEsL8RNoD/VXcMyykXn4mOrWILowYOAVEsly4jacV wBq0cg8Y9HwEvZ86OkjMwotorEAM6K352DdBOX8NzIEFEkpRSxORZPHQ5IfRisxCx2 zwkwZWdZ3HhymK3mYldyw1g0AxkGkHKOG8K00+QFdkVwKugFL8fBfSkifDHpSvb6og U5PGGxnrgJEVbi03nYDKLV1pFWvgok39PaRLzKAskgrP3gtuiZ1MGYDaQ6A8SIhKRe raWdiclW4lrVw== Received: from [10.3.16.29] (broadband-188-255-38-164.ip.moscow.rt.ru [188.255.38.164]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) (Authenticated sender: a.makhmutov@postgrespro.ru) by mail.postgrespro.ru (Postfix/465) with ESMTPSA id 8A5685FFF5; Mon, 6 Apr 2026 17:30:51 +0300 (MSK) Message-ID: Date: Mon, 6 Apr 2026 17:30:51 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) To: Melanie Plageman Cc: PostgreSQL Hackers , Andres Freund , Kirill Reshke , Andrey Borodin , Robert Haas , Heikki Linnakangas References: Content-Language: en-US From: Alexey Makhmutov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2026/04/06 10:19:00 #28376530 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Melanie, Sorry for the late note for the already committed patch, but I have a question on the last part of the 'heap_xlog_prune_freeze' function related to the FSM update (it was committed in add323d -'Eliminate XLOG_HEAP2_VISIBLE from vacuum phase III'). Currently it contains the following logic: ... Size freespace = 0; ... if (BufferIsValid(buffer)) { if ((xlrec.flags & (XLHP_HAS_REDIRECTIONS | XLHP_HAS_DEAD_ITEMS | XLHP_HAS_NOW_UNUSED_ITEMS)) || (vmflags & VISIBILITYMAP_VALID_BITS)) freespace = PageGetHeapFreeSpace(BufferGetPage(buffer)); ... UnlockReleaseBuffer(buffer); } ... if (freespace > 0) XLogRecordPageWithFreeSpace(rlocator, blkno, freespace); ... My question is about the last check ('freespace > 0') - do we really want to call 'XLogRecordPageWithFreeSpace' only if 'freespace' is greater than 0? As I understand, the zero value is a perfectly valid output of the 'PageGetHeapFreeSpace' call (i.e. page has no space or no free line items while we mark all rows as frozen/visible), but with the current implementation we will skip FSM update in such case. Maybe we need to use additional flag (i.e. 'need_fsm_update'), set it before calling 'PageGetHeapFreeSpace' and then check before the 'XLogRecordPageWithFreeSpace' invocation? Thanks, Alexey