RE: Parallel INSERT (INTO ... SELECT ...)

From: "tsunakawa(dot)takay(at)fujitsu(dot)com" <tsunakawa(dot)takay(at)fujitsu(dot)com>
To: 'Greg Nancarrow' <gregn4422(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Antonin Houska <ah(at)cybertec(dot)at>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Parallel INSERT (INTO ... SELECT ...)
Date: 2021-01-25 05:37:29
Message-ID: TYAPR01MB2990C2770C4D083760CCE0E7FEBD0@TYAPR01MB2990.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

From: Greg Nancarrow <gregn4422(at)gmail(dot)com>
> > (1)
> Yes, you're right the wording is not right (and I don't really like
> the wording used before the patch).
>
> Perhaps it could say:
>
> (Note that we do allow CREATE TABLE AS, INSERT INTO...SELECT, SELECT
> INTO, and CREATE MATERIALIZED VIEW to use parallel plans. However, as
> of now, other than in the case of INSERT INTO...SELECT, only the leader
> backend
> writes into a completely new table. In the future, we can extend it to
> allow workers for the
> other commands to write into the table. However, to allow parallel
> updates and deletes, we
> have to solve other problems, especially around combo CIDs.)

That looks good to me, thanks.

> > (4)
> You could, but I'm not sure it would make the code easier to read,
> especially for those who don't know !isParallelWorker() means it's a
> parallel leader.
...
> I really can't see a problem. PrepareParallelMode() is only needed
> prior to execution of a parallel plan, so it's not needed for "other
> call sites" using EnterParallelMode().
My frank first impressions were (and are):

* Why do we have to call a separate function for preparation despite the actual entering follows immediately? We can do necessary preparation in the entering function.

* Those who read the parallel index build and parallel VACUUM code for the first time might be startled at the missing PrepareParallelMode() call: "Oh, EnterParallelMode() is called without preparation unlike the other site I saw the other day. Isn't this a but?"

> Perhaps the name can be changed to disassociate it from generic
> EnterParallelMode() usage. So far, I've only thought of long names
> like: PrepareParallelModePlanExec().
> Ideas?

What PrepareParallelMode() handles is the XID and command ID, which are managed by access/transam/ module and are not executor-specific. It's natural (or at least not unnatural) that EnterParallelMode() prepares them, because EnterParallelMode() is part of access/transam/.

Regards
Takayuki Tsunakawa

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2021-01-25 05:48:41 Re: Single transaction in the tablesync worker?
Previous Message Amit Langote 2021-01-25 05:23:35 Re: ModifyTable overheads in generic plans