Subject Re: [firebird-support] MAX vs. FIRST 1
Author PenWin
> 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"?

Interesting replies to your question. I always thought MAX is faster because
I would have expected the database to simply consult the index and come out
with the largest value, as opposed to first selecting all matching rows,
then sorting them and finally returning the first one. (Assuming I have an
applicable index, obviously)

Pepak