Re: Using GROUPING SETS with more than one set disables predicate pushdown? - Mailing list pgsql-performance

From Tom Lane
Subject Re: Using GROUPING SETS with more than one set disables predicate pushdown?
Date
Msg-id 1703.1511275766@sss.pgh.pa.us
Whole thread Raw
In response to Using GROUPING SETS with more than one set disables predicate pushdown?  (Zakhar Shapurau <zak@zvs.no>)
Responses Re: Using GROUPING SETS with more than one set disables predicate pushdown?  (Andres Freund <andres@anarazel.de>)
Re: Using GROUPING SETS with more than one set disables predicate pushdown?  (Andres Freund <andres@anarazel.de>)
List pgsql-performance
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
containsaggregates (obviously) or    * volatile functions (since a HAVING clause is supposed to be executed    * only
onceper group).  We also can't do this if there are any nonempty    * grouping sets; moving such a clause into WHERE
wouldpotentially change    * the results, if any referenced column isn't present in all the grouping    * sets.  (If
thereare 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


pgsql-performance by date:

Previous
From: "Henrik Cednert (Filmlance)"
Date:
Subject: pg_dump 3 times as slow after 8.4 -> 9.5 upgrade
Next
From: Marco Nietz
Date:
Subject: Re: [PERFORM] POWA doesn't show queries executed