Re: Speedup truncations of temporary relation forks - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Speedup truncations of temporary relation forks
Date
Msg-id 6828cb10-ef85-4a3a-81eb-425858b64b43@oss.nttdata.com
Whole thread Raw
In response to Re: Speedup truncations of temporary relation forks  (Daniil Davydov <3danissimo@gmail.com>)
List pgsql-hackers

On 2025/05/31 23:23, Daniil Davydov wrote:
> Hi,
> 
> On Sat, May 31, 2025 at 7:41 PM Fujii Masao <masao.fujii@oss.nttdata.com> wrote:
>>
>> Here are a few review comments on the patch:
>>
>> +               for (j = 0; j < nforks; j++)
>>                  {
>> -                       InvalidateLocalBuffer(bufHdr, true);
>> +                       if ((buf_state & BM_TAG_VALID) &&
>> +                               BufTagGetForkNum(&bufHdr->tag) == forkNum[j] &&
>> +                               bufHdr->tag.blockNum >= firstDelBlock[j])
>> +                       {
>> +                               InvalidateLocalBuffer(bufHdr, true);
>> +                       }
>>
>> It looks like the "buf_state & BM_TAG_VALID" check can be moved
>> outside the loop, along with the BufTagMatchesRelFileLocator() check.
>> That would avoid unnecessary looping.
>>
>> Also, should we add a "break" right after calling InvalidateLocalBuffer()?
>> Since the buffer has already been invalidated, continuing the loop
>> may not be necessary.
> 
> Thanks for the review! I'll fix both remarks. Please see the v2 patch.

Thanks for updating the patch! I have no further comments.

Since both you and Dilip have confirmed the performance improvement by
the patch, probably we can mark this patch as Ready for Committer?
The actual commit will need to wait until development for v19 opens, though.

Regards,

-- 
Fujii Masao
NTT DATA Japan Corporation




pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: C11 / VS 2019
Next
From: Dilip Kumar
Date:
Subject: Re: Speedup truncations of temporary relation forks