MySQL只能使用定义索引的最左边部份
发表于:2024-10-02 作者:千家信息网编辑
千家信息网最后更新 2024年10月02日,实验环境:MySQL 5.7.171、表结构如下,在id,name,tx列建立主键mysql> show create table txtx;+-------+--------------------
千家信息网最后更新 2024年10月02日MySQL只能使用定义索引的最左边部份
实验环境:MySQL 5.7.17
1、表结构如下,在id,name,tx列建立主键
mysql> show create table txtx;+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Table | Create Table |+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| txtx | CREATE TABLE `txtx` ( `id` int(11) NOT NULL, `name` char(2) NOT NULL, `tx` char(3) NOT NULL, `id1` int(11) DEFAULT NULL, PRIMARY KEY (`id`,`name`,`tx`)) ENGINE=InnoDB DEFAULT CHARSET=gbk |+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+1 row in set (0.00 sec)
2、查看执行计划
mysql> explain select * from txtx where id=1 and id1 =1 and tx='tx';+----+-------------+-------+------------+------+---------------+---------+---------+-------+------+----------+-------------+| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |+----+-------------+-------+------------+------+---------------+---------+---------+-------+------+----------+-------------+| 1 | SIMPLE | txtx | NULL | ref | PRIMARY | PRIMARY | 4 | const | 1 | 33.33 | Using where |+----+-------------+-------+------------+------+---------------+---------+---------+-------+------+----------+-------------+1 row in set, 1 warning (0.00 sec)
从上面执行计划可以看出,尽管查询在where语句中使用了id与tx列,但只使用了id列,原因是MySQL只能使用定义索引的最左边部分。
索引
原因
环境
结构
语句
部分
实验
查询
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
经典日漫小伙子是个软件开发师
网络安全中的注入什么意思
采访数据库技术经理
小学生网络安全知识
我的世界服务器存档管理器
软件开发语言是干什么的
数据库同步性与唯一性
长沙医学院网络安全
储能安全测试数据库
亿云网络技术有限公司
信用卡用什么作为储存数据库
gta5有些什么服务器
淄博布扣网络技术有限公司
手机软件开发教程视频
rtu与电脑数据库
网络安全法对政府
播放网络安全走手抄报
医院网络安全整体情况报告
网络安全排查检查表
数据库归档的分类
软件开发前景如何贴吧
吴中区便宜服务器市面价
网络安全管理的三个要素是
检索图书的数据库
高级数据库技术题库
服务器维护和系统设计
电子书 服务器
浙江推荐的软件开发行业标准
靖安软件开发有限公司
网络安全排查检查表