Skip site navigation (1) Skip section navigation (2)

Re: wip: functions median and percentile

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Fetter <david(at)fetter(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: wip: functions median and percentile
Date: 2010-10-04 06:36:48
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-rrreviewers
2010/10/4 Greg Stark <gsstark(at)mit(dot)edu>:
> On Sun, Oct 3, 2010 at 7:06 AM, Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> wrote:
>> And I'm now thinking about how to make median happen in window
>> aggregate.
> If you were to do this by extending tuplesort what extra features
> would tuplesort need?

I don't think we need to extend tuplesort when we do it. IMO this can
make happen by fetching all the values in the frame and performing
sort once, then getting current position and calculate median. The
only thing I consider is to mark and to go to the demanded position in
tuplesort like tuplestore, but actually we can manage to median()
without such facilities.

> How do existing windowed aggregates work if you specify an order by on
> the aggregate? Do they resort for every output row?

I don't know the true specification of median() nor the behavior of it
in other RDBs, but I bet median is median and ORDER BY in window
clause doesn't affect its result. ORDER BY specifies only the frame


Hitoshi Harada

In response to


pgsql-hackers by date

Next:From: Markus WannerDate: 2010-10-04 06:48:45
Subject: Re: is sync rep stalled?
Previous:From: Pavel StehuleDate: 2010-10-04 06:05:48
Subject: Re: patch: tsearch - some memory diet

pgsql-rrreviewers by date

Next:From: Dean RasheedDate: 2010-10-04 06:58:44
Subject: Re: wip: functions median and percentile
Previous:From: Pavel StehuleDate: 2010-10-03 17:31:18
Subject: Re: wip: functions median and percentile

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group