Re: [HACKERS] Question regarding new windowing functions in 8.4devel

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Fetter <david(at)fetter(dot)org>
Cc: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: [HACKERS] Question regarding new windowing functions in 8.4devel
Date: 2009-01-16 18:05:26
Message-ID: 8928.1232129126@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

David Fetter <david(at)fetter(dot)org> writes:
> Basically, there is no way I've found so far to qualify any window
> function in the target list, which makes a giant POLA violation.

The FM points out in at least two places that window functions logically
execute on the output of the WHERE/GROUP BY/HAVING steps. It's
conceptually nonsensical to have window function calls in those clauses,
just like it's conceptually nonsensical to use aggregates in WHERE.

Therefore, if you need to filter on the results of the window functions,
you put them into a sub-select and write the filter condition in the
outer query. This is required by spec, and it really does not matter
whether you find it astonishing.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Davis 2009-01-16 18:07:26 Re: Query sometimes takes down server
Previous Message David Fetter 2009-01-16 17:52:08 Re: [HACKERS] Question regarding new windowing functions in 8.4devel

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-01-16 18:09:18 Re: FWD: Re: Updated backslash consistency patch
Previous Message Tom Lane 2009-01-16 17:56:59 Re: FATAL: could not open relation pg_tblspc/491086/467369/491103: No such file or directory