Re: SELECT LIMIT 1 VIEW Performance Issue

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: K C Lau <kclau60(at)netvigator(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: SELECT LIMIT 1 VIEW Performance Issue
Date: 2005-09-23 11:15:41
Message-ID: 1127474141.19345.10.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, 2005-09-22 at 18:40 +0800, K C Lau wrote:
> > > esdt=> explain analyze select PlayerID,AtDate from Player a
> > > where PlayerID='22220' and AtDate = (select b.AtDate from Player b
> > > where b.PlayerID = a.PlayerID order by b.PlayerID desc, b.AtDate desc
> > > LIMIT 1);

I think you should try:

select distinct on (PlayerID) PlayerID,AtDate from Player a
where PlayerID='22220' order by PlayerId, AtDate Desc;

Does that work for you?

Best Regards, Simon Riggs

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Arjen van der Meijden 2005-09-23 11:19:55 Re: How to determine cause of performance problem?
Previous Message Michael Stone 2005-09-23 11:05:00 Re: How to determine cause of performance problem?