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

From Dilip Kumar
Subject Re: Parallel Inserts in CREATE TABLE AS
Date
Msg-id CAFiTN-shB5M=fr=byFxz5E8qa_EYAFmWwxRFE43T9oGXfqw_3g@mail.gmail.com
Whole thread Raw
In response to Re: Parallel Inserts in CREATE TABLE AS  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
List pgsql-hackers
On Fri, Dec 25, 2020 at 9:54 AM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:
>
> On Fri, Dec 25, 2020 at 7:12 AM vignesh C <vignesh21@gmail.com> wrote:
> > On Thu, Dec 24, 2020 at 11:29 AM Amit Kapila <amit.kapila16@gmail.com> wrote:
> > >
> > > On Thu, Dec 24, 2020 at 10:25 AM vignesh C <vignesh21@gmail.com> wrote:
> > > >
> > > > On Tue, Dec 22, 2020 at 2:16 PM Bharath Rupireddy
> > > > <bharath.rupireddyforpostgres@gmail.com> wrote:
> > > > >
> > > > > On Tue, Dec 22, 2020 at 12:32 PM Bharath Rupireddy
> > > > > Attaching v14 patch set that has above changes. Please consider this
> > > > > for further review.
> > > > >
> > > >
> > > > Few comments:
> > > > In the below case, should create be above Gather?
> > > > postgres=# explain  create table t7 as select * from t6;
> > > >                             QUERY PLAN
> > > > -------------------------------------------------------------------
> > > >  Gather  (cost=0.00..9.17 rows=0 width=4)
> > > >    Workers Planned: 2
> > > >  ->  Create t7
> > > >    ->  Parallel Seq Scan on t6  (cost=0.00..9.17 rows=417 width=4)
> > > > (4 rows)
> > > >
> > > > Can we change it to something like:
> > > > -------------------------------------------------------------------
> > > > Create t7
> > > >  -> Gather  (cost=0.00..9.17 rows=0 width=4)
> > > >   Workers Planned: 2
> > > >   ->  Parallel Seq Scan on t6  (cost=0.00..9.17 rows=417 width=4)
> > > > (4 rows)
> > > >
> > >
> > > I think it is better to have it in a way as in the current patch
> > > because that reflects that we are performing insert/create below
> > > Gather which is the purpose of this patch. I think this is similar to
> > > what the Parallel Insert patch [1] has for a similar plan.
> > >
> > >
> > > [1] - https://commitfest.postgresql.org/31/2844/
> > >
> >
> > Also another thing that I felt was that actually the Gather nodes will actually do the insert operation, the Create
tablewill be done earlier itself. Should we change Create table to Insert table something like below:
 
> >                              QUERY PLAN
> > -------------------------------------------------------------------
> >  Gather  (cost=0.00..9.17 rows=0 width=4)
> >    Workers Planned: 2
> >  ->  Insert table2 (instead of Create table2)
> >    ->  Parallel Seq Scan on table1  (cost=0.00..9.17 rows=417 width=4)
>
> IMO, showing Insert under Gather makes sense if the query is INSERT
> INTO SELECT as it's in the other patch [1]. Since here it is a CTAS
> query, so having Create under Gather looks fine to me. This way we can
> also distinguish the EXPLAINs of parallel inserts in INSERT INTO
> SELECT and CTAS.

I don't think that is a problem because now also if we EXPLAIN CTAS it
will appear like we are executing the select query because that is
what we are planning for only the select part.  So now if we are
including the INSERT in the planning and pushing the insert under the
gather then it will make more sense to show INSERT instead of showing
CREATE.  Let's see what others think.

--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: [Patch] Optimize dropping of relation buffers using dlist
Next
From: Amit Kapila
Date:
Subject: Re: Parallel Inserts in CREATE TABLE AS