Subject SELECT MAX
Author Bud Millwood
We have an application that executes this statement on a table having 2
million records (PK is an integer type and indexed):

SELECT MAX(ALL PK) FROM MyTable;

It takes quite a long time - maybe 10 minutes or so.

I've tried this in isql:

SELECT FIRST 1 * FROM MyTable ORDER BY PK DESC;

"SELECT FIRST 1" doesn't seem to limit the query, only the result. This takes
the same amount of time as the SELECT MAX (ALL PK)

So... what's an efficient way to get the maximum PK that doesn't require
scanning every record?

- Bud