2010/10/4 Greg Stark <gsst...@mit.edu>: > On Sun, Oct 3, 2010 at 7:06 AM, Hitoshi Harada <umi.tan...@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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers