Hi,
we have a table with about 6.000.000 rows. There is an index on a column with the name id which is an integer and serves as primary key.
When we execute select max(id) from theTable; it takes about 10 seconds. Explain analyze returns:
Due to the open-ended nature of PG's aggregate function system, it can't see inside the max() function to realise it doesn't need all the values.
Fortune favours the flexible however - the simple workaround is to use the equivalent:
SELECT id FROM theTable ORDER BY id DESC LIMIT 1;
-- Richard Huxton Archonet Ltd
---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]