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

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 (view raw or flat)
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

pgsql-performance by date

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

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