pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: David Rowley <david.rowley@2ndquadrant.com>
Cc: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: ajax@tvsquared.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: inconsistent results querying table partitioned by date
Date: Tue, 14 May 2019 16:58:20 -0400
Message-ID: <28453.1557867500@sss.pgh.pa.us> (raw)
In-Reply-To: <e903adfc-c7a5-58f9-6b7f-16ab6f48be5c@lab.ntt.co.jp>
References: <FAD28A83-AC73-489E-A058-2681FA31D648@tvsquared.com>
	<24525.1557444159@sss.pgh.pa.us>
	<49cd5235-cbe6-e686-8014-85c1e45efe56@lab.ntt.co.jp>
	<20190510.153337.236910404.horiguchi.kyotaro@lab.ntt.co.jp>
	<90aeaf38-270a-7e45-6b7d-af2e3d1e3719@lab.ntt.co.jp>
	<20307.1557522309@sss.pgh.pa.us>
	<a0bca4f7-b493-4d0a-8080-8dad3748c5ae@lab.ntt.co.jp>
	<CAKJS1f92Uq+SV+WKKa+B5Fd9PcrwhYFsvxUudm_9F8egi4paXQ@mail.gmail.com>
	<d7878f1f-f7c5-4f23-127e-ced79a64ddf1@lab.ntt.co.jp>
	<CAKJS1f-xHgnr0QVfGtt9BU38kB8a5fp4Y=CYbChV8xSqw6pZ9w@mail.gmail.com>
	<e903adfc-c7a5-58f9-6b7f-16ab6f48be5c@lab.ntt.co.jp>

Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> writes:
> On 2019/05/14 15:09, David Rowley wrote:
>> Do you think it's a bad idea to do it this way?

> As I mentioned above, I think this may be quite a bit of code churn for
> enforcing a policy that's elsewhere enforced in a much simpler manner.
> How about deferring this to committer?

Not sure I'll be the one to commit this, but ...

I don't much like the approach in
v1-0003-Fix-planner-to-not-prune-partitions-with-non-immu.patch
because (a) it appears to me to add duplicative expression mutability
testing, which is kind of expensive since that adds syscache lookups,
plus it adds such tests even for clauses that aren't going to match any
partition keys; and (b) it's extremely nonobvious that this restricts
plan-time pruning and not run-time pruning.  I do see that
prune_append_rel_partitions is used only for the former; but you sure
as heck can't deduce that from any of its comments, so somebody might
try to use it for run-time pruning.

So I think David's got the right idea that match_clause_to_partition_key
is where to handle this, and I like the fact that his patch explicitly
represents whether we're trying to do run-time or plan-time pruning.
I agree it's kind of invasive, and I wonder why.  Shouldn't the
additional flag just be a field in the "context" struct, instead of
being a separate parameter that has to be laboriously passed through
many call levels?

(For myself, I'd have made it just a bool not an enum, given that
I don't foresee a need for additional values.  But that's definitely
a matter of preference.)

Also, I'm a bit confused by the fact that we seem to have a bunch
of spare-parts patches in this thread.  What combination is actually
being proposed for commit?

			regards, tom lane





view thread (41+ messages)  latest in thread

Message-ID: <28453.1557867500@sss.pgh.pa.us>
Permalink:  ../28453.1557867500@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28453.1557867500@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Langote_Amit_f8@lab.ntt.co.jp, david.rowley@2ndquadrant.com, horiguchi.kyotaro@lab.ntt.co.jp
  Subject: Re: inconsistent results querying table partitioned by date
  In-Reply-To: <28453.1557867500@sss.pgh.pa.us>
  References: <FAD28A83-AC73-489E-A058-2681FA31D648@tvsquared.com> <24525.1557444159@sss.pgh.pa.us> <49cd5235-cbe6-e686-8014-85c1e45efe56@lab.ntt.co.jp> <20190510.153337.236910404.horiguchi.kyotaro@lab.ntt.co.jp> <90aeaf38-270a-7e45-6b7d-af2e3d1e3719@lab.ntt.co.jp> <20307.1557522309@sss.pgh.pa.us> <a0bca4f7-b493-4d0a-8080-8dad3748c5ae@lab.ntt.co.jp> <CAKJS1f92Uq+SV+WKKa+B5Fd9PcrwhYFsvxUudm_9F8egi4paXQ@mail.gmail.com> <d7878f1f-f7c5-4f23-127e-ced79a64ddf1@lab.ntt.co.jp> <CAKJS1f-xHgnr0QVfGtt9BU38kB8a5fp4Y=CYbChV8xSqw6pZ9w@mail.gmail.com> <e903adfc-c7a5-58f9-6b7f-16ab6f48be5c@lab.ntt.co.jp> <28453.1557867500@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox