2020-06-07:mysql中varchar类型的id,where id=1,会用到索引吗?int 类型的id,where id=”1“,会用到索引吗?为什么?

答案来自群员:
对于int类型id,查询的varchar 类型 ‘1’会隐式转换成 1,‘1’和 1都能正常走索引;
对于varchar类型id,查询的int 类型 1不会转换,‘1’正常走索引,1走全表;

评论

猜你喜欢

转载自blog.csdn.net/weixin_48502062/article/details/106684435