Re: wip: functions median and percentile - Mailing list pgsql-hackers

From Hitoshi Harada
Subject Re: wip: functions median and percentile
Date
Msg-id AANLkTikaVTKJ1rpcEbWNUcYiZBJ7Q-qph-XNit4vE2wf@mail.gmail.com
Whole thread Raw
In response to Re: wip: functions median and percentile  (Greg Stark <gsstark@mit.edu>)
Responses Re: wip: functions median and percentile
List pgsql-hackers
2010/10/4 Greg Stark <gsstark@mit.edu>:
> On Sun, Oct 3, 2010 at 7:06 AM, Hitoshi Harada <umi.tanuki@gmail.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
boundary.

Regards,



-- 
Hitoshi Harada


pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: patch: tsearch - some memory diet
Next
From: Markus Wanner
Date:
Subject: Re: is sync rep stalled?