Re: [PERFORM] SELECT DISTINCT Performance Issue

2005-06-08 Thread George Essig
On 6/2/05, K C Lau [EMAIL PROTECTED] wrote: ... select DISTINCT ON (PlayerID) PlayerID,AtDate from Player where PlayerID='0' order by PlayerID desc, AtDate desc; The Player table has primary key (PlayerID, AtDate) representing data over time and the query gets the latest data for a

Re: [PERFORM] SELECT DISTINCT Performance Issue

2005-06-08 Thread George Essig
On 6/8/05, K C Lau [EMAIL PROTECTED] wrote: Both keys are text fields. Does it make any difference if PlayerID were integer? It can make a difference in speed and integrity. If the column is an integer, the storage on disk could be smaller for the column and the related indexes. If the the

Re: [PERFORM] SELECT DISTINCT Performance Issue

2005-06-06 Thread PFC
Previously, we have also tried to use LIMIT 1 instead of DISTINCT, but the performance was no better: select PlayerID,AtDate from Player where PlayerID='0' order by PlayerID desc, AtDate desc LIMIT 1 The DISTINCT query will pull out all the rows and keep only one, so the one with

Re: [PERFORM] SELECT DISTINCT Performance Issue

2005-06-06 Thread K C Lau
At 19:45 05/06/06, PFC wrote: Previously, we have also tried to use LIMIT 1 instead of DISTINCT, but the performance was no better: select PlayerID,AtDate from Player where PlayerID='0' order by PlayerID desc, AtDate desc LIMIT 1 The DISTINCT query will pull out all the rows and