max or not max?
am 14.11.2006 16:42:00 von markHello,
I have a question about the use of the function "max" and the use of index.
I have a table with primary key "nr" (DataType Integer).
when i do
desc select max(nr) from data_sales
the result is:
id: 1
select_type: SIMPLE
table: NULL
type: NULL
possible_keys NULL
key: NULL
key_len: NULL
ref: NULL
rows: NULL
Extra Select tables optimized away
if i rewrite my query to:
desc select nr from data_sales order by nr desc limit 1
the result is:
.....
table: data_sales
type: index
possible_keys: NULL
key: PRIMARY
....
rows: Using index
Does this mean the second query is better? or is "max" otherwise optimized?
Thanks!