On Mon, Aug 14, 2006 at 09:09:51AM -0300, Jorge Godoy wrote: > Chris <dmagick@xxxxxxxxx> writes: > > P.S. I'm sure in older versions this query wouldn't use an index: > > select max(id) from table; > > It doesn't. You'd have to do what you did: "order by <x> desc limit 1" to > have it using indexes... > > > I'm not sure about 8.0+.. hence doing an order by the id desc limit 1. > > I also have to test it... But I still keep using the "order by desc" syntax Excerpt from the 8.1 Release Notes: Automatically use indexes for MIN() and MAX() (Tom) In previous releases, the only way to use an index for MIN() or MAX() was to rewrite the query as SELECT col FROM tab ORDER BY col LIMIT 1. Index usage now happens automatically. -- Michael Fuhr