Re: Speedup truncations of temporary relation forks

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Daniil Davydov <3danissimo(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Speedup truncations of temporary relation forks
Date: 2025-05-31 00:48:52
Message-ID: aDpR9Kg3ieOQDGXi@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 30, 2025 at 06:01:16PM +0700, Daniil Davydov wrote:
> 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.

Applying the same kind of optimization for local buffers makes sense
here, even if the impact is more limited than regular relations.

> I understand that it will look kinda ugly, but it will increase
> performance for sure.

I guess it does. Do you have numbers to share with a test case?

Please make sure to add this patch to the next commit fest.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-05-31 01:34:47 Re: POC: Carefully exposing information without authentication
Previous Message Michael Paquier 2025-05-31 00:44:01 Re: Add comment explaining why queryid is int64 in pg_stat_statements