Subject Re: [firebird-support] MAX vs. FIRST 1
Author Alexandre Benson Smith
Thomas wrote:
> Hi,
>
> which of the following two statements would be better or is there
> some other statement that I should rather use? There will be in
> excess of 500,000 records per store. It seems to me that the "FIRST
> 1" would be the better one to execute but is it really going to make
> that much difference? I have seen the "SELECT MAX" statement take as
> long as 16 minutes when the server is under load, I think that this
> is due to garbage collection. So could I avoid garbage collection by
> using the "FIRST 1"?
>
> Thanks
> Thomas Ellis
>

Apart from what others have already said, you could add a descending
index on the column you use with MAX, it should increase the performance
dramatically.

see you !

--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br