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

Re: ORDER BY and LIMIT with SubSelects

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Ron St-Pierre <rstpierre(at)syscor(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: ORDER BY and LIMIT with SubSelects
Date: 2004-01-21 18:36:56
Message-ID: 20040121183656.GC11684@wolff.to (view raw or flat)
Thread:
Lists: pgsql-performance
On Wed, Jan 21, 2004 at 09:18:18 -0800,
  Ron St-Pierre <rstpierre(at)syscor(dot)com> wrote:
> 
> My question is in regards to steps 2 and 3 above. Is there some way that 
> I can combine both steps into one to save some time?
 
TIP 4: Don't 'kill -9' the postmaster
SELECT SS.* FROM
(SELECT DISTINCT ON (nonUniqField)
 first, second, third, cost, payDate, nonUniqField
 FROM histdata
 WHERE userID = 19048 AND cost IS NOT NULL 
 ORDER BY nonUniqField, payDate DESC LIMIT 200
)
SS  
ORDER BY payDate;

In response to

pgsql-performance by date

Next:From: Josh BerkusDate: 2004-01-21 19:06:06
Subject: Re: Queries with timestamps
Previous:From: ArnauDate: 2004-01-21 18:25:15
Subject: Queries with timestamps

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