mysql的in会不会让索引失效?
网络编程 2021-07-05 14:37www.168986.cn编程入门
今天长沙网络推广就为大家分享一篇关于mysql的in会不会让索引失效?,长沙网络推广觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随长沙网络推广来看看吧
mysql的in会让索引失效吗?不会! 看结果
mysql> desc select from tb_province where name in ('lily3', 'lily2', 'lily1'); +----+-------------+-------------+------------+------+---------------+------+---------+------+--------+----------+-------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------------+------------+------+---------------+------+---------+------+--------+----------+-------------+ | 1 | SIMPLE | tb_province | NULL | ALL | NULL | NULL | NULL | NULL | 108780 | 30.00 | Using where | +----+-------------+-------------+------------+------+---------------+------+---------+------+--------+----------+-------------+ 1 row in set, 1 warning (0.00 sec) mysql> alter table tb_province add index g(name); Query OK, 0 rows affected (0.29 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> desc select from tb_province where name in ('lily3', 'lily2', 'lily1'); +----+-------------+-------------+------------+-------+---------------+------+---------+------+------+----------+-----------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------------+------------+-------+---------------+------+---------+------+------+----------+-----------------------+ | 1 | SIMPLE | tb_province | NULL | range | g | g | 34 | NULL | 3 | 100.00 | Using index condition | +----+-------------+-------------+------------+-------+---------------+------+---------+------+------+----------+-----------------------+ 1 row in set, 1 warning (0.00 sec) mysql>
顺便说下,in查出的结果,不一定按in排序, 如下
mysql> select from tb_province where name in ('lily3', 'lily2', 'lily1'); +----+-------+-------+------+------+------+------+------+------+------+------+------+------+------+ | id | name | score | x | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | +----+-------+-------+------+------+------+------+------+------+------+------+------+------+------+ | 1 | lily1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 2 | lily2 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 3 | lily3 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +----+-------+-------+------+------+------+------+------+------+------+------+------+------+------+ 3 rows in set (0.00 sec) mysql>
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对狼蚁SEO的支持。如果你想了解更多相关内容请查看狼蚁网站SEO优化相关链接
编程语言
- 如何快速学会编程 如何快速学会ug编程
- 免费学编程的app 推荐12个免费学编程的好网站
- 电脑怎么编程:电脑怎么编程网咯游戏菜单图标
- 如何写代码新手教学 如何写代码新手教学手机
- 基础编程入门教程视频 基础编程入门教程视频华
- 编程演示:编程演示浦丰投针过程
- 乐高编程加盟 乐高积木编程加盟
- 跟我学plc编程 plc编程自学入门视频教程
- ug编程成航林总 ug编程实战视频
- 孩子学编程的好处和坏处
- 初学者学编程该从哪里开始 新手学编程从哪里入
- 慢走丝编程 慢走丝编程难学吗
- 国内十强少儿编程机构 中国少儿编程机构十强有
- 成人计算机速成培训班 成人计算机速成培训班办
- 孩子学编程网上课程哪家好 儿童学编程比较好的
- 代码编程教学入门软件 代码编程教程