Re: Parallel Inserts in CREATE TABLE AS

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: "Hou, Zhijie" <houzj(dot)fnst(at)cn(dot)fujitsu(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Luc Vlaming <luc(at)swarm64(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Zhihong Yu <zyu(at)yugabyte(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Subject: Re: Parallel Inserts in CREATE TABLE AS
Date: 2020-12-15 12:23:22
Message-ID: CALj2ACUw4=14F4TFKb-p+2EDoWJpobto_jESx9qzA8C-QSVpxQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 15, 2020 at 5:48 PM Hou, Zhijie <houzj(dot)fnst(at)cn(dot)fujitsu(dot)com> wrote:
> > A little explanation about how to push down the ctas info in append.
> >
> > 1. about how to ignore tuple cost in this case.
> > IMO, it create gather path under append like the following:
> > query_planner
> > -make_one_rel
> > --set_base_rel_sizes
> > ---set_rel_size
> > ----set_append_rel_size (*)
> > -----set_rel_size
> > ------set_subquery_pathlist
> > -------subquery_planner
> > --------grouping_planner
> > ---------apply_scanjoin_target_to_paths
> > ----------generate_useful_gather_paths
> >
> > set_append_rel_size seems the right place where we can check and set a flag
> > to ignore tuple cost later.
> > We can set the flag for two cases when there is no parent path will be
> > created(such as : limit,sort,distinct...):
> > i) query_level is 1
> > ii) query_level > 1 and we have set the flag in the parent_root.
> >
> > The case ii) is to check append under append:
> > Append
> > ->Append
> > ->Gather
> > ->Other plan
> >
> > 2.about how to push ctas info down.
> >
> > We traversing the whole plans tree, and we only care Append and Gather type.
> > Gather: It set the ctas dest info and returned true at once if the gathernode
> > does not have projection.
> > Append: It will recursively traversing the subplan of Appendnode and will
> > reture true if one of the subplan can be parallel.
> >
> > +PushDownCTASParallelInsertState(DestReceiver *dest, PlanState *ps) {
> > + bool parallel = false;
> > +
> > + if(ps == NULL)
> > + return parallel;
> > +
> > + if(IsA(ps, AppendState))
> > + {
> > + AppendState *aps = (AppendState *) ps;
> > + for(int i = 0; i < aps->as_nplans; i++)
> > + {
> > + parallel |=
> > PushDownCTASParallelInsertState(dest, aps->appendplans[i]);
> > + }
> > + }
> > + else if(IsA(ps, GatherState) && !ps->ps_ProjInfo)
> > + {
> > + GatherState *gstate = (GatherState *) ps;
> > + parallel = true;
> > +
> > + ((DR_intorel *) dest)->is_parallel = true;
> > + gstate->dest = dest;
> > + ps->plan->plan_rows = 0;
> > + }
> > +
> > + return parallel;
> > +}
>
> So sorry for my miss, my last patch has some mistakes.
> Attatch the new one.

Thanks for the append patches. Basically your changes look good to me.
I'm merging them to the original patch set and adding the test cases
to cover these cases. I will post the updated patch set soon.

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-12-15 12:43:48 Re: [HACKERS] logical decoding of two-phase transactions
Previous Message Hou, Zhijie 2020-12-15 12:18:06 RE: Parallel Inserts in CREATE TABLE AS