首页 > 关于MYSQL的性能问题?

关于MYSQL的性能问题?

select count(1) from A
where 
1=1  and `status`=0 and `type` in (1,2,3,4,5) and 
`type` ='1' AND time >= "1451185080";

select count(1) from A
where
1=1   and `status`=0 and 
`type` ='1' AND time >= "1451185080";

的性能一样吗?


如果mysql优化器不够智能的话,第一个sql就会先找到type满足1,2,3,4,5的,然后再找type=1的,肯定比第二个sql性能差。
具体试试就知道了


下面一个性能应该会好一点。
1=1会被优化掉,然后in语句貌似不能索引命中。在其他SQL上in语句会索引命中的

【热门文章】
【热门文章】