Re: Fast COPY FROM based on batch insert - Mailing list pgsql-hackers

From Etsuro Fujita
Subject Re: Fast COPY FROM based on batch insert
Date
Msg-id CAPmGK15jd6gEt_XyswQ4uEG6XVdz9DNC5uqW1KK=1A_ehLTEYw@mail.gmail.com
Whole thread Raw
In response to Re: Fast COPY FROM based on batch insert  (Andrey Lepikhov <a.lepikhov@postgrespro.ru>)
Responses Re: Fast COPY FROM based on batch insert
Re: Fast COPY FROM based on batch insert
List pgsql-hackers
On Fri, Jul 22, 2022 at 3:39 PM Andrey Lepikhov
<a.lepikhov@postgrespro.ru> wrote:
> Analyzing multi-level heterogeneous partitioned configurations I
> realized, that single write into a partition with a trigger will flush
> buffers for all other partitions of the parent table even if the parent
> haven't any triggers.
> It relates to the code:
> else if (insertMethod == CIM_MULTI_CONDITIONAL &&
>    !CopyMultiInsertInfoIsEmpty(&multiInsertInfo))
> {
>    /*
>     * Flush pending inserts if this partition can't use
>     * batching, so rows are visible to triggers etc.
>     */
>    CopyMultiInsertInfoFlush(&multiInsertInfo, resultRelInfo);
> }
>
> Why such cascade flush is really necessary, especially for BEFORE and
> INSTEAD OF triggers?

BEFORE triggers on the chosen partition might query the parent table,
not just the partition, so I think we need to do this so that such
triggers can see all the rows that have been inserted into the parent
table until then.

Best regards,
Etsuro Fujita



pgsql-hackers by date:

Previous
From: Junwang Zhao
Date:
Subject: Re: [PATCH v1] eliminate duplicate code in table.c
Next
From: Kyotaro Horiguchi
Date:
Subject: Re: Remove useless arguments in ReadCheckpointRecord().