From: Logan Bowers <logan.bowers@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Richard Guo <guofenglinux@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Optimizer Doesn't Push Down Where Expressions on Rollups
Date: Wed, 11 Mar 2020 09:58:11 -0700
Message-ID: <90491802-76A3-4AE8-AD2E-1646B68016FC@gmail.com> (raw)
In-Reply-To: <2865.1583935603@sss.pgh.pa.us>
References: <CAMbWs49zx2WFAzWGsay-X8PLdwboujtGsjSydJtsHa9xbAKHiA@mail.gmail.com>
<2865.1583935603@sss.pgh.pa.us>
Just in case it wasn’t obvious from the example, I’m talking about only cases where the all groups in the grouping set share a subset of columns in common and those are the columns being conditioned in the WHERE clause.
I get it if it’s not something actionable, but it is a bummer to see query time explode when going from one grouping set to two grouping sets. :/
Cheers, and I’ve been a big fan of y’alls work for going on two decades now. Thank you!
> On Mar 11, 2020, at 7:06 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> 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
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: logan.bowers@gmail.com, tgl@sss.pgh.pa.us, guofenglinux@gmail.com
Subject: Re: Optimizer Doesn't Push Down Where Expressions on Rollups
In-Reply-To: <90491802-76A3-4AE8-AD2E-1646B68016FC@gmail.com>
References: <CAMbWs49zx2WFAzWGsay-X8PLdwboujtGsjSydJtsHa9xbAKHiA@mail.gmail.com> <2865.1583935603@sss.pgh.pa.us> <90491802-76A3-4AE8-AD2E-1646B68016FC@gmail.com>
* 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