Re: speeding up planning with partitions

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, "Imai, Yoshikazu" <imai(dot)yoshikazu(at)jp(dot)fujitsu(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: speeding up planning with partitions
Date: 2019-02-01 14:11:35
Message-ID: CAKJS1f9LkQ=w4cq2_OaW05=mw8H_jQofWHiK0w3VVP-nSkUUmA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 1 Feb 2019 at 23:01, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:
> Please rebase.

I had a short list of other things I noticed when making a partial
pass over the patch again.

I may as well send these now if there's a new version on the way:

1. I think it's okay to convert the following:

/*
* Adjust all_baserels to replace the original target relation with the
* child target relation. Copy it before modifying though.
*/
subroot->all_baserels = bms_copy(root->all_baserels);
subroot->all_baserels = bms_del_member(subroot->all_baserels,
root->parse->resultRelation);
subroot->all_baserels = bms_add_member(subroot->all_baserels,
subroot->parse->resultRelation);

into:
/* Adjust all_baserels */
subroot->all_baserels = adjust_child_relids(root->all_baserels, 1, &appinfo);

2. Any reason to do:

/*
* Generate access paths for the entire join tree.
*
* For UPDATE/DELETE on an inheritance parent, join paths should be
* generated for each child result rel separately.
*/
if (root->parse->resultRelation &&
root->simple_rte_array[root->parse->resultRelation]->inh)

instead of just checking: if (root->inherited_update)

3. This seems like useless code in set_inherit_target_rel_sizes().

/*
* If parallelism is allowable for this query in general, see whether
* it's allowable for this childrel in particular. For consistency,
* do this before calling set_rel_size() for the child.
*/
if (root->glob->parallelModeOK)
set_rel_consider_parallel(subroot, childrel, childRTE);

parallelModeOK is only ever set for SELECT. Likely it's fine just to
replace these with:

+ /* We don't consider parallel paths for UPDATE/DELETE
statements */
+ childrel->consider_parallel = false;

or perhaps it's fine to leave it out since build_simple_rel() sets it to false.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2019-02-01 14:16:32 Re: Delay locking partitions during INSERT and UPDATE
Previous Message David Rowley 2019-02-01 14:09:41 Re: speeding up planning with partitions