pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Aggregate FILTER option is broken in v10
Date: Mon, 16 Oct 2017 11:12:09 -0400
Message-ID: <2275.1508166729@sss.pgh.pa.us> (raw)
In-Reply-To: <30065.1508161354@sss.pgh.pa.us>
References: <30065.1508161354@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

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



view thread (3+ messages)  latest in thread

Message-ID: <2275.1508166729@sss.pgh.pa.us>
Permalink:  ../2275.1508166729@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2275.1508166729@sss.pgh.pa.us

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de
  Subject: Re: Aggregate FILTER option is broken in v10
  In-Reply-To: <2275.1508166729@sss.pgh.pa.us>
  References: <30065.1508161354@sss.pgh.pa.us> <2275.1508166729@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