Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e475V-000575-Kb for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Oct 2017 15:13:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e475V-0003Qb-7A for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Oct 2017 15:13:53 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e473w-0000ce-7t for pgsql-hackers@postgresql.org; Mon, 16 Oct 2017 15:12:16 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e473t-0007Fh-Ok for pgsql-hackers@postgresql.org; Mon, 16 Oct 2017 15:12:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v9GFC9gc002276; Mon, 16 Oct 2017 11:12:10 -0400 From: Tom Lane To: Andres Freund cc: pgsql-hackers@postgresql.org Subject: Re: Aggregate FILTER option is broken in v10 In-reply-to: <30065.1508161354@sss.pgh.pa.us> References: <30065.1508161354@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 16 Oct 2017 09:42:34 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2274.1508166729.1@sss.pgh.pa.us> Date: Mon, 16 Oct 2017 11:12:09 -0400 Message-ID: <2275.1508166729@sss.pgh.pa.us> 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 I wrote: > I think possibly the best answer is to revert 8ed3f11bb. We could > think about some compromise solution like merging the projections > only for aggregates without FILTER. But that would require two > code paths through the relevant functions in nodeAgg.c, which would > be a substantial maintenance burden; and the extra branches required > means that this would be a net negative for performance in the > simplest case with only one aggregate. Hmm ... on closer inspection, the only performance-critical place where this matters is advance_aggregates, and that already has a check for whether the particular aggregate has a filter. So we could do something like /* Skip anything FILTERed out */ if (filter) { // existing code to eval/check filter expr + + /* Now it's safe to evaluate this agg's arguments */ + slot = ExecProject(pertrans->argproj); } + else + slot = aggstate->evalslot; which seems like a pretty minimal extra cost for the normal case with no filter. Let me see what I can make of that ... regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers