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

Re: [GENERAL] question (or feature-request): over ( partition by ... order by LIMIT N)

From: David Fetter <david(at)fetter(dot)org>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] question (or feature-request): over ( partition by ... order by LIMIT N)
Date: 2010-03-25 21:17:31
Message-ID: 20100325211731.GA16362@fetter.org (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-hackers
On Wed, Mar 24, 2010 at 06:31:59PM +0100, A. Kretschmer wrote:
> Hello @all,
> 
> I know, i can do:
> 
> select * from (select ... row_number() over (...) ...) foo where
> row_number < N
> 
> to limit the rows per group, but the inner select has to retrieve
> the whole set of records and in the outer select most of them
> discarded.

That sounds like the optimizer's falling down on the job.  Would this
be difficult to fix?

Cheers,
David.
-- 
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david(dot)fetter(at)gmail(dot)com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2010-03-25 22:50:19
Subject: Re: Re: [GENERAL] question (or feature-request): over ( partition by ... order by LIMIT N)
Previous:From: Simon RiggsDate: 2010-03-25 19:48:06
Subject: Re: Re: [COMMITTERS] pgsql: Make standby server continuously retry restoring the next WAL

pgsql-general by date

Next:From: Tom LaneDate: 2010-03-25 21:43:50
Subject: Re: Performing FETCH ALL from a SCROLL CURSOR failing to return results
Previous:From: Eliot GableDate: 2010-03-25 21:10:46
Subject: Performing FETCH ALL from a SCROLL CURSOR failing to return results

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