Re: [HACKERS] GSets: Fix bug involving GROUPING and HAVING together

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, andres(at)anarazel(dot)de
Cc: Atri Sharma <atri(dot)jiit(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Postgres-Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [HACKERS] GSets: Fix bug involving GROUPING and HAVING together
Date: 2015-07-24 10:34:22
Message-ID: 874mkt3l59.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

>>>>> "Andrew" == Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:

Andrew> The other is that in subquery_planner, the optimization of
Andrew> converting HAVING clauses to WHERE clauses is suppressed if
Andrew> parse->groupingSets isn't empty. (It is empty if there's either
Andrew> no group by clause at all, or if there's exactly one grouping
Andrew> set, which must not be empty, however derived.) This is costing
Andrew> us some optimizations, especially in the case of an explicit
Andrew> GROUP BY () clause; I'll look into this.

I'm inclined to go with the simplest approach here, which copies the
quals if there are grouping sets. The only way we could safely move a
qual without copying is if we can show that none of the grouping sets is
empty, that is (), and at this point the grouping set list has not been
expanded so it's not trivial to determine that.

Patch attached.

--
Andrew (irc:RhodiumToad)

Attachment Content-Type Size
gsets_having_pushdown.patch text/x-patch 717 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jeevan Chalke 2015-07-24 11:18:33 Re: [HACKERS] GSets: Fix bug involving GROUPING and HAVING together
Previous Message bakhtawarashiq 2015-07-24 04:25:58 BUG #13517: installaion error

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavan Deolasee 2015-07-24 10:56:11 Re: Reduce ProcArrayLock contention
Previous Message Andres Freund 2015-07-24 10:08:39 Re: Free indexed_tlist memory explicitly within set_plan_refs()