From: Tom Lane <tgl@sss.pgh.pa.us>
To: Zakhar Shapurau <zak@zvs.no>
Cc: pgsql-performance@postgresql.org
Subject: Re: Using GROUPING SETS with more than one set disables predicate pushdown?
Date: Tue, 21 Nov 2017 09:49:26 -0500
Message-ID: <1703.1511275766@sss.pgh.pa.us> (raw)
In-Reply-To: <1511262257.3219920.1179611992.260EC9D9@webmail.messagingengine.com>
References: <1511262257.3219920.1179611992.260EC9D9@webmail.messagingengine.com>
Zakhar Shapurau <zak@zvs.no> writes:
> Using GROUPING SETS with more than one set disables predicate pushdown?
It looks like this is a case that no one's gotten round to yet.
The comment in the relevant code is
* In some cases we may want to transfer a HAVING clause into WHERE. We
* cannot do so if the HAVING clause contains aggregates (obviously) or
* volatile functions (since a HAVING clause is supposed to be executed
* only once per group). We also can't do this if there are any nonempty
* grouping sets; moving such a clause into WHERE would potentially change
* the results, if any referenced column isn't present in all the grouping
* sets. (If there are only empty grouping sets, then the HAVING clause
* must be degenerate as discussed below.)
Presumably, we could examine the grouping sets to identify column(s)
present in all sets, and then allow the optimization for clauses that
reference only such columns. Or maybe I'm misreading the comment
(but then it needs clarification).
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, zak@zvs.no
Subject: Re: Using GROUPING SETS with more than one set disables predicate pushdown?
In-Reply-To: <1703.1511275766@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