Speedup truncations of temporary relation forks

From: Daniil Davydov <3danissimo(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Speedup truncations of temporary relation forks
Date: 2025-05-30 11:01:16
Message-ID: CAJDiXggNqsJOH7C5co4jA8nDk8vw-=sokyh5s1_TENWnC6Ofcg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
For now we fully scan local buffers for each fork of the temporary
relation that we want to truncate (in order to drop its buffers). It
happens in the function "DropRelationBuffers".
There used to be the same problem for regular tables (i.e. shared
buffers) and it was fixed in commit [1] and now shared buffers are
scanned only one time for those three relation forks.
I suggest making the same fix for temporary relations. See attached patch.

[1] 6d05086c0a79e50d8e91ed953626ec7280cd2481

BTW, I see that we call "DropRelationBuffers" separately for relation,
toast table and indexes. What if we collect all this information in
advance and iterate over the local/shared buffers only once?
I understand that it will look kinda ugly, but it will increase
performance for sure.

--
Best regards,
Daniil Davydov

Attachment Content-Type Size
v1-0001-Speedup-temp-table-truncation.patch text/x-patch 3.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-05-30 11:02:28 Re: Replication slot is not able to sync up
Previous Message Amul Sul 2025-05-30 10:34:56 Re: Replication slot is not able to sync up