Primary key not equal zero reduce performance

问题: Does primary key not equal zero id != 0 in where clause reduce query performance? Does this checking prevent taking the advantage of indexing? 回答1: Does primary ke...

问题:

Does primary key not equal zero id != 0 in where clause reduce query performance? Does this checking prevent taking the advantage of indexing?


回答1:

Does primary key not equal zero id != 0 in where clause reduce query performance?

It does in the way that you end up with a full table scan.

Does this checking prevent taking the advantage of indexing?

Yes. Since id != 0 will almost always evaluate to true you end up retrieving all of the table data, thus not taking advantage of your index at all.

  • 发表于 2019-01-20 23:25
  • 阅读 ( 189 )
  • 分类:网络文章

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除