Re: inconsistent results querying table partitioned by date

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
Cc: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, Alan Jackson <ajax(at)tvsquared(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: inconsistent results querying table partitioned by date
Date: 2019-05-16 16:06:37
Message-ID: 14871.1558022797@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> writes:
> Given the way gen_partprune_steps() is designed [1], while it may be
> possible to discard steps generated by run-time pruning that need not be
> applied during execution because they would've already been fully applied
> during plan-time pruning, it seems hard to keep around *partial* steps
> generated during plan-time pruning and use them for run-time pruning after
> filling missing expressions from run-time quals. Filling the missing
> expressions into existing steps part seems hard.

Yeah. It seems like the way to make some progress on this would be
to annotate the steps when they're generated as to whether they involve
any run-time component or not. However, we might end up making multiple
calls anyway because of the possibility of parameterized paths having
additional qual clauses to work with, so I'm not clear on exactly how
we could reduce the number of times we do gen_partprune_steps. It's
not something we could fix now in any case.

However, I'm still not real happy with analyze_partkey_exprs();
its analysis seems well short of ideal. I notice that in the sort
of case suggested upthread, with more than one opclause contributing
to a step, it's entirely possible for it to report that both initial
and runtime pruning are needed even though only the latter is really
possible. Perhaps this could be improved a bit by making the analysis
operate per-step rather than being totally per-expression.

Anyway, I've pushed David's patch now, on to look at Amit's.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2019-05-16 16:15:39 BUG #15810: Using custom directory on external HDD gives permission error
Previous Message PG Bug reporting form 2019-05-16 11:29:26 BUG #15809: pgadmin4 installation fails on Fedora 30