Re: Use a bulk-write buffer access strategy for TOAST inserts

From: Andres Freund <andres(at)anarazel(dot)de>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Use a bulk-write buffer access strategy for TOAST inserts
Date: 2026-10-21 12:31:09
Message-ID: wvvawftvpcatdeze5rviq4xqcvfhy6euqze2tpcytek33q7q7i@qcwvycc5xsff
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Bertrand and I were just chatting. Comments excerpted from that discussion
below:

On 2026-10-16 07:45:26 +0000, Bertrand Drouvot wrote:
> Bulk insert operations use a BAS_BULKWRITE strategy for the main relation, but
> TOAST rows are inserted without it. Large amounts of TOAST data can therefore
> evict useful shared buffers. This has already been discussed in [1].

My comment about this aspect was that I
don't think we should use strategies for toast insertions, as toast accesses
cause random IO, which makes the evictions of the just-toasted data cause much
higher cost than evicting table data itself.

> 0001:
>
> Buffer access strategies are generally owned by the operation that creates them.
> BulkInsertState is an exception: it owns both its BAS_BULKWRITE strategy and
> relation local insertion state. Those objects have different useful lifetimes:
> one bulk operation may need several relation local states while all of them should
> share the same buffer ring.
>
> Pass the strategy to GetBulkInsertState(), leaving its allocation and release
> to the caller.

Here I think the better direction would be to move the creation of the "bulk
state" into tableam itself, and then make it reused across all DML
operations. For that it needs to be a state that can be extended by different
AMs.

I think we may have had patches floating around for that...

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirk Wolak 2026-10-21 12:49:04 Re: PoC: Simplify recovery after dropping a table by LOGGING the restore LSN
Previous Message Henson Choi 2026-10-21 12:03:31 [DEPARSE] A COLLATE clause in the URI of XMLNAMESPACES does not read back