Getting Max value extremely slow.

job419

New Member
I need to get the maximum value for a field in a table. Using the following statement, it is taking about 25 minutes to return the maximum value.

SELECT max(notes.key)
FROM notes

I'm using the Merant ODBC driver, and there are over 9.5 million records in the table. Is there a better way to get the max value?
 

tamhas

ProgressTalk.com Sponsor
Store it somewhere denormalized. Seriously, the only way to obtain the max value without having it stored somewhere is to read 9.5 million records ... are you surprised that takes a while?
 
Top