Re: speeding up planning with partitions

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Imai Yoshikazu <yoshikazu_i443(at)live(dot)jp>, "jesper(dot)pedersen(at)redhat(dot)com" <jesper(dot)pedersen(at)redhat(dot)com>, "Imai, Yoshikazu" <imai(dot)yoshikazu(at)jp(dot)fujitsu(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: speeding up planning with partitions
Date: 2019-03-28 10:16:47
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2019/03/28 14:03, Tom Lane wrote:
> Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> writes:
>> On 2019/03/27 23:57, Tom Lane wrote:
>>> Yeah, there's something to be said for having plancat.c open each table
>>> *and store the Relation pointer in the RelOptInfo*, and then close that
>>> again at the end of planning rather than immediately. If we can't avoid
>>> these retail table_opens without a great deal of pain, that's the
>>> direction I'd tend to go in. However it would add some overhead, in
>>> the form of a need to traverse the RelOptInfo array an additional time.
>> Just to be sure, do you mean we should do that now or later (David said
>> "in the long term")?
> It's probably not high priority, though I wonder how much time is being
> eaten by the repeated table_opens.

It took me a couple of hours to confirm this, but it seems significantly
less than it takes to go over the simple_rel_array one more time to close
the relations. The scan of simple_rel_array to close the relations needs
to be done once per query_planner() invocation, whereas I'd hoped this
could be done, say, in add_rtes_to_flat_rtable() that has to iterate over
the range table anyway. That's because we call query_planner multiple
times on the same query in a few cases, viz. build_minmax_path(),

Within query_planner(), table is opened in expand_inherited_rtentry(),
get_relation_constraints(), get_relation_data_width(), and
build_physical_tlist(), of which the first two are more common. So, we
end up doing table_open() 3 times on average for any given relation, just
inside query_planner().


In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Banck 2019-03-28 10:19:44 Re: Progress reporting for pg_verify_checksums
Previous Message Nagaura, Ryohei 2019-03-28 10:11:09 RE: Timeout parameters