Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZJNdp-0004k6-Cq for pgsql-hackers@arkaria.postgresql.org; Sun, 26 Jul 2015 15:15:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZJNdo-0008EI-Ul for pgsql-hackers@arkaria.postgresql.org; Sun, 26 Jul 2015 15:15:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZJNdn-0008BC-Ml; Sun, 26 Jul 2015 15:15:03 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZJNdl-00012P-3W; Sun, 26 Jul 2015 15:15:03 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id C3352860004; Sun, 26 Jul 2015 17:15:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-6.1 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p5DDC4D3B.dip0.t-ipconnect.de [93.220.77.59]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 5F892860002; Sun, 26 Jul 2015 17:14:57 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id EA5D110105B; Sun, 26 Jul 2015 17:14:56 +0200 (CEST) Date: Sun, 26 Jul 2015 17:14:56 +0200 From: Andres Freund To: Andrew Gierth Cc: Jeevan Chalke , Atri Sharma , PostgreSQL Hackers , Postgres-Bugs Subject: Re: GSets: Fix bug involving GROUPING and HAVING together Message-ID: <20150726151456.GD12755@awork2.anarazel.de> References: <87si8rqba3.fsf@news-spur.riddles.org.uk> <874mkt3l59.fsf@news-spur.riddles.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <874mkt3l59.fsf@news-spur.riddles.org.uk> X-Pg-Spam-Score: -4.2 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 2015-07-24 11:34:22 +0100, Andrew Gierth wrote: > >>>>> "Andrew" == Andrew Gierth 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. I pushed this to both master and 9.5. While this isn't strictly a bugfix, it seemed better to keep the branches the same at this point. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers