Re: Speedup truncations of temporary relation forks
Daniil Davydov <3danissimo@gmail.com>
From: Daniil Davydov <3danissimo@gmail.com>
To: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: Michael Paquier <michael@paquier.xyz>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-05-31T14:23:19Z
Lists: pgsql-hackers
Attachments
- v2-0001-Speedup-temp-table-truncation.patch (text/x-patch) patch v2-0001
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.
--
Best regards,
Daniil Davydov
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Speed up truncation of temporary relations.
- 78ebda66bf26 19 (unreleased) landed
-
Speedup truncations of relation forks.
- 6d05086c0a79 13.0 cited