Re: Fast COPY FROM based on batch insert

Поиск
Список
Период
Сортировка
От Etsuro Fujita
Тема Re: Fast COPY FROM based on batch insert
Дата
Msg-id CAPmGK160mQENUMOjMa03-QRR77wiZrA375tiT6KY_wP-hsNu2Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Fast COPY FROM based on batch insert  (Etsuro Fujita <etsuro.fujita@gmail.com>)
Ответы Re: Fast COPY FROM based on batch insert  (Andrey Lepikhov <a.lepikhov@postgrespro.ru>)
Список pgsql-hackers
On Tue, Sep 27, 2022 at 6:03 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:
> I will review the patch a bit more, but I feel that it is
> in good shape.

One thing I noticed is this bit added to CopyMultiInsertBufferFlush()
to run triggers on the foreign table.

+           /* Run AFTER ROW INSERT triggers */
+           if (resultRelInfo->ri_TrigDesc != NULL &&
+               (resultRelInfo->ri_TrigDesc->trig_insert_after_row ||
+                resultRelInfo->ri_TrigDesc->trig_insert_new_table))
+           {
+               Oid         relid =
RelationGetRelid(resultRelInfo->ri_RelationDesc);
+
+               for (i = 0; i < inserted; i++)
+               {
+                   TupleTableSlot *slot = rslots[i];
+
+                   /*
+                    * AFTER ROW Triggers might reference the tableoid column,
+                    * so (re-)initialize tts_tableOid before evaluating them.
+                    */
+                   slot->tts_tableOid = relid;
+
+                   ExecARInsertTriggers(estate, resultRelInfo,
+                                        slot, NIL,
+                                        cstate->transition_capture);
+               }
+           }

Since foreign tables cannot have transition tables, we have
trig_insert_new_table=false.  So I simplified the if test and added an
assertion ensuring trig_insert_new_table=false.  Attached is a new
version of the patch.  I tweaked some comments a bit as well.  I think
the patch is committable.  So I plan on committing it next week if
there are no objections.

Best regards,
Etsuro Fujita

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "houzj.fnst@fujitsu.com"
Дата:
Сообщение: RE: Perform streaming logical transactions by background workers and parallel apply
Следующее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: START_REPLICATION SLOT causing a crash in an assert build