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 22:50:50
Message-ID: 7099.1558047050@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> In other words, as I compose this I'm talking myself into the
> idea that invoking gen_partprune_steps three times (for planner,
> executor startup, and executor runtime, with corresponding
> filters on which clauses can be used) is the only safe near-term
> fix. In the future we can look at cutting down the repetitive
> costs that entails.

Here's a really quick and dirty POC along that line. It's unfinished
but I'm out of time for today. I think the executor side of it is OK,
but the planner side is crufty: it lacks logic to decide whether
either the initial pruning or exec pruning steps are unnecessary.
And I didn't update most of the comments either.

I think the rule for "exec pruning is unnecessary" could probably
just be "we didn't find any exec params in the prune steps", since
that would imply that the initial steps include everything.
I don't see an equally cheap way to decide that initial pruning
is useless, though. Thoughts?

Also, it seems like we could save at least some of the planning expense by
having the PARTCLAUSE_INITIAL pass report back whether it had discarded
any Param-bearing clauses or not. If not, there's definitely no need to
run the PARTCLAUSE_EXEC pass.

regards, tom lane

Attachment Content-Type Size
generate-separate-initial-and-exec-pruning-steps-1.patch text/x-diff 31.5 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2019-05-16 23:43:51 Re: BUG #15810: Using custom directory on external HDD gives permission error
Previous Message Tom Lane 2019-05-16 20:37:50 Re: inconsistent results querying table partitioned by date