开发者

Mysql LIMIT operator - equal efficency when not using it?

开发者 https://www.devze.com 2023-02-20 01:26 出处:网络
How is it that when i use 开发者_如何学CLIMIT, mysql checks the same number of rows? and how do i solve this?

How is it that when i use 开发者_如何学CLIMIT, mysql checks the same number of rows? and how do i solve this?

Mysql LIMIT operator - equal efficency when not using it?


The Where clause is processed first. Once the matches are found, the limit is applied on the result set, so all of the rows have to be evaluated to determine if they match the conditions before the limit can be applied.


The explain output is misleading. Mysql will evaluate the query using the where clause and such, but it'll stop after it find LIMIT number of matching rows (1 in this case). This is a known issue with mysql: http://bugs.mysql.com/bug.php?id=50168

To clarify... the limit clause will work as expected... it's only the explain output that's inaccurate.

0

精彩评论

暂无评论...
验证码 换一张
取 消