Re: should INSERT SELECT use a BulkInsertState? - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: should INSERT SELECT use a BulkInsertState?
Date
Msg-id 20200511061934.GC88791@paquier.xyz
Whole thread Raw
In response to should INSERT SELECT use a BulkInsertState?  (Justin Pryzby <pryzby@telsasoft.com>)
List pgsql-hackers
On Fri, May 08, 2020 at 02:25:45AM -0500, Justin Pryzby wrote:
> Seems to me it should, at least conditionally.  At least if there's a function
> scan or a relation or ..
>
> I mentioned a bit about our use-case here:
> https://www.postgresql.org/message-id/20200219173742.GA30939%40telsasoft.com
> => I'd prefer our loaders to write their own data rather than dirtying large
> fractions of buffer cache and leaving it around for other backends to clean up.

Does it matter in terms of performance and for which cases does it
actually matter?

> diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
> index 4fee043bb2..daf365f181 100644
> --- a/src/include/nodes/execnodes.h
> +++ b/src/include/nodes/execnodes.h
> @@ -14,6 +14,7 @@
>  #ifndef EXECNODES_H
>  #define EXECNODES_H
>
> +#include "access/heapam.h"
>  #include "access/tupconvert.h"
>  #include "executor/instrument.h"
>  #include "fmgr.h"
> @@ -1177,6 +1178,7 @@ typedef struct ModifyTableState
>      List      **mt_arowmarks;    /* per-subplan ExecAuxRowMark lists */
>      EPQState    mt_epqstate;    /* for evaluating EvalPlanQual rechecks */
>      bool        fireBSTriggers; /* do we need to fire stmt triggers? */
> +    BulkInsertState    bistate;    /* State for bulk insert like INSERT SELECT */

I think that this needs more thoughts.  You are introducing a
dependency between some generic execution-related nodes and heap, a
table AM.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: calling procedures is slow and consumes extra much memory againstcalling function
Next
From: Tatsuro Yamada
Date:
Subject: Re: PG 13 release notes, first draft