pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: logan.bowers@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Optimizer Doesn't Push Down Where Expressions on Rollups
Date: Wed, 11 Mar 2020 10:06:43 -0400
Message-ID: <2865.1583935603@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMbWs49zx2WFAzWGsay-X8PLdwboujtGsjSydJtsHa9xbAKHiA@mail.gmail.com>
References: <CAMbWs49zx2WFAzWGsay-X8PLdwboujtGsjSydJtsHa9xbAKHiA@mail.gmail.com>

Richard Guo <guofenglinux@gmail.com> writes:
> In your case, the WHERE clauses would get pushed down into the subquery
> for both queries, with/without the ROLLUP. But since the subquery uses
> grouping/grouping sets, the WHERE clauses would be put in HAVING of the
> subquery.

Right, we do successfully push the clauses into HAVING of the subquery.

> Then when we plan for the subquery, we will decide whether a HAVING
> clause can be transfered into WHERE. Usually we do not do that if there
> are any nonempty grouping sets. Because if any referenced column isn't
> present in all the grouping sets, moving such a clause into WHERE would
> potentially change the results.

Yeah.  I think that it might be safe if the proposed clause can
be proven strict for (some subset of?) the grouping columns, because
that would eliminate the rollup grouping sets where those columns
come out NULL because they aren't being grouped on.  (This could then
also factor into throwing away those grouping sets, perhaps.)

Anyway, this is not a bug; it's a proposed planner improvement, and
not a trivial one.

			regards, tom lane





view thread (6+ messages)  latest in thread

Message-ID: <2865.1583935603@sss.pgh.pa.us>
Permalink:  ../2865.1583935603@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2865.1583935603@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, guofenglinux@gmail.com, logan.bowers@gmail.com
  Subject: Re: Optimizer Doesn't Push Down Where Expressions on Rollups
  In-Reply-To: <2865.1583935603@sss.pgh.pa.us>
  References: <CAMbWs49zx2WFAzWGsay-X8PLdwboujtGsjSydJtsHa9xbAKHiA@mail.gmail.com> <2865.1583935603@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