选择MAX() vs .根据列DESC LIMIT 1选择列顺序

时间:2022-06-13 04:03:47

sources said that the aggregate function MAX() has a better performance that select order desc limit 1

有消息称聚合函数MAX()具有更好的性能,可以选择order desc limit 1

but after executing the query from a table with 43000 records, MAX() takes about 1.5 seconds and the other takes 350ms

但是,在从有43000条记录的表执行查询之后,MAX()大约需要1.5秒,另一个需要350ms

and when both are used in inner queries, for about 1 minute MAX() is still executing while the other yield results for 94ms

当在内部查询中同时使用这两种方法时,MAX()仍然在执行大约1分钟,而其他结果为94ms

can anyone enlighten me? I'd really appreciate it

谁能开导我?我真的很感激

1 个解决方案

#1


2  

It is all about the INDEXes and the keys that you use. use EXPLAIN to see where your bottlenecks are - http://dev.mysql.com/doc/refman/5.0/en/using-explain.html.

这都是关于你使用的索引和键。使用EXPLAIN查看瓶颈在哪里—http://dev.mysql.com/doc/refman/5.0/en/using-explain.html。

#1


2  

It is all about the INDEXes and the keys that you use. use EXPLAIN to see where your bottlenecks are - http://dev.mysql.com/doc/refman/5.0/en/using-explain.html.

这都是关于你使用的索引和键。使用EXPLAIN查看瓶颈在哪里—http://dev.mysql.com/doc/refman/5.0/en/using-explain.html。