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

Re: introduction of WIP window function patch

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: "H(dot)Harada" <umi(dot)tanuki(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: introduction of WIP window function patch
Date: 2008-07-05 14:20:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On Sat, Jul 05, 2008 at 07:04:29PM +0900, H.Harada wrote:
> Hi,
> As I proposed a month before, I am working on window function.

Very nice!

> The problem is, as written in the "Things to discussed" section of the
> document, how you define window functions (e.g. RANK()). My idea is to
> treat them as specialized functions such as SET OF functions and mark
> it in pg_proc. But this doesn't resolve RANK() boundary problem.

Actually, I would make RANK() and ROW_NUMBER() act more like
aggregates. ISTM you have two kinds of window functions:

- aggregation: a result is calculated over a set and the result copied
  across all the rows.
- order depenadant: same as above, but the result is different for each

I think you could make the latter work using the current aggregation
setup, just by calling the final_func for each row rather than just
once at the end.

That would make RANK() a normal aggrgate which returns the number of
distinct values seen so far (assuming input is ordered) and
ROW_NUMBER() is just an alias for COUNT().

I hope this is clear, let me know if it doesn't make sense.

Have a nice day,
Martijn van Oosterhout   <kleptog(at)svana(dot)org>
> Please line up in a tree and maintain the heap invariant while 
> boarding. Thank you for flying nlogn airlines.

In response to


pgsql-hackers by date

Next:From: Dave PageDate: 2008-07-05 15:00:41
Subject: Re: Explain XML patch v2
Previous:From: H.HaradaDate: 2008-07-05 10:04:29
Subject: introduction of WIP window function patch

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