pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Aggregate transition state merging vs. hypothetical set functions
Date: Thu, 12 Oct 2017 20:12:51 -0400
Message-ID: <7197.1507853571@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKJS1f_Ubu8sZfyK=vpi6va79Q4ycqVhHDokSpw5ouDZ4hbYFw@mail.gmail.com>
References: <4834.1507849699@sss.pgh.pa.us>
	<CAKJS1f9oZeDB=gxYMDDjrTg3+6MF-NxqcLp1QmGxKmR3xPXBhA@mail.gmail.com>
	<6042.1507851674@sss.pgh.pa.us>
	<CAKJS1f_Ubu8sZfyK=vpi6va79Q4ycqVhHDokSpw5ouDZ4hbYFw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

David Rowley <david.rowley@2ndquadrant.com> writes:
> On 13 October 2017 at 12:41, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Yeah, we would probably also want to check the flag in nodeWindowAgg.
>> Not sure exactly how that should play out --- maybe we end up with
>> a tri-valued property "works as normal agg without merging, works
>> as normal agg with merging, works as window agg".

> hmm, maybe I'm lacking imagination here, but surely the final function
> is either destructive or it's not? I can't understand what the
> difference between nodeAgg.c calling the finalfn multiple times on the
> same state and nodeWindowAgg.c doing it. Maybe there's something I'm
> not accounting for that you are?

nodeWindowAgg is doing something more: not only is it calling the finalfn
repeatedly, but it's continuing to mutate the transition state in between.
The ordered-set aggs provide a counterexample to considering that to be
equivalent to state merging.  The OSAs can cope with state merging as
long as they have a flag to make sure only the first finalfn does
tuplesort_performsort ... but that's not good enough to make them workable
as window aggs.  Once we sort, we can't absorb more rows into the
tuplesort object.

			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 (12+ messages)  latest in thread

Message-ID: <7197.1507853571@sss.pgh.pa.us>
Permalink:  ../7197.1507853571@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7197.1507853571@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, david.rowley@2ndquadrant.com, hlinnaka@iki.fi
  Subject: Re: Aggregate transition state merging vs. hypothetical set functions
  In-Reply-To: <7197.1507853571@sss.pgh.pa.us>
  References: <4834.1507849699@sss.pgh.pa.us> <CAKJS1f9oZeDB=gxYMDDjrTg3+6MF-NxqcLp1QmGxKmR3xPXBhA@mail.gmail.com> <6042.1507851674@sss.pgh.pa.us> <CAKJS1f_Ubu8sZfyK=vpi6va79Q4ycqVhHDokSpw5ouDZ4hbYFw@mail.gmail.com> <7197.1507853571@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