Re: Parallel Inserts in CREATE TABLE AS - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: Parallel Inserts in CREATE TABLE AS
Date
Msg-id CAA4eK1LEeYdaX4nkyqR_MbEk1LCCj9PpOVkc5c+QbGY+0C=uTA@mail.gmail.com
Whole thread Raw
In response to Re: Parallel Inserts in CREATE TABLE AS  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Responses Re: Parallel Inserts in CREATE TABLE AS
List pgsql-hackers
On Thu, Oct 15, 2020 at 9:14 AM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:
>
> On Wed, Oct 14, 2020 at 6:16 PM Amit Kapila <amit.kapila16@gmail.com> wrote:
> >
> > > For prepared statements, the parallelism will not be picked and so is
> > > parallel insertion.
> >
> > Hmm, I am not sure what makes you say this statement. The parallelism
> > is enabled for prepared statements since commit 57a6a72b6b.
> >
>
> Thanks for letting me know this. I misunderstood the parallelism for prepared statements. Now, I verified with a
properuse case(see below), where I had a prepared statement, CTAS having EXECUTE, in this case too parallelism is
pickedand parallel insertion happened with the patch proposed in this thread. Do we have any problems if we allow
parallelinsertion for these cases? 
>
> PREPARE myselect AS SELECT * FROM t1;
> EXPLAIN ANALYZE CREATE TABLE t1_test AS EXECUTE myselect;
>
> I think the commit 57a6a72b6b has not added any test cases, isn't it good to add one in prepare.sql or
select_parallel.sql?
>

I am not sure if it is worth as this is not functionality which is too
complex or there are many chances of getting it broken.

> >
> > > 1. How to represent the parallel insert for CTAS in explain plans? The
> > > explain CTAS shows the plan for only the SELECT part. How about having
> > > some textual info along with the Gather node? I'm not quite sure on
> > > this point, any suggestions are welcome.
> >
> > I am also not sure about this point because we don't display anything
> > for the DDL part in explain. Can you propose by showing some example
> > of what you have in mind?
> >
>
> I thought we could have something like this.
>  -----------------------------------------------------------------------------
>      Gather  (cost=1000.00..108738.90 rows=0 width=8)
>      Workers Planned: 2 Parallel Insert on t_test1
>         ->  Parallel Seq Scan on t_test  (cost=0.00..106748.00 rows=4954 width=8)
>              Filter: (many < 10000)
>  -----------------------------------------------------------------------------
>

maybe something like below:
Gather  (cost=1000.00..108738.90 rows=0 width=8)
   -> Create t_test1
       ->  Parallel Seq Scan on t_test

I don't know what is the best thing to do here. I think for the
temporary purpose you can keep something like above then once the
patch is matured then we can take a separate opinion for this.

--
With Regards,
Amit Kapila.



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Parallel copy
Next
From: Ajin Cherian
Date:
Subject: Re: [HACKERS] logical decoding of two-phase transactions