空间索引关键字mysql_mysql测试where子句中使用or关键字能否用到索引

这篇博客探讨了在MySQL 5.5.48版本中,无论是MyISAM还是InnoDB存储引擎都无法有效利用索引的问题。文章指出,在后续版本如MySQL 5.7中,MyISAM引擎对索引的使用得到了改进。内容主要围绕数据库索引的使用、性能优化以及不同MySQL版本之间的差异展开。
摘要由CSDN通过智能技术生成

create table if not exists tbl_item_1(

`id` int(10) not null auto_increment,

`name` varchar(20) not null,

`categoryid` int(10) not null,

`price` double(6,2) not null,

`desc` varchar(20) ,

primary key (`id`),

key `categoryid` (`categoryid`)

)engine=innodb default charset=utf8 auto_increment=1;

insert into tbl_item_1(`name` ,`categoryid`,`price`,`desc` ) values('三星 Galaxy S7 edge(G9350)4GB+32GB 雪晶白',1,3399,'Super AMOLED三星双曲面2K 屏,支持无线充电!');

insert into tbl_item_1(`name` ,`categoryid`,`price`,`desc` ) values('联想(Lenovo)拯救者R720',2,6399.00,'专业游戏键盘新模具全新设计!');

insert into tbl_item_1(`name` ,`categoryid`,`price`,`desc` ) values('Apple iPhone 7 Plus (A1661) 128G 黑色',1,6099,'全国不限流量任意刷,下单更享200M光纤0元购!');

insert into tbl_item_1(`name` ,`categoryid`,`price`,`desc` ) values('索尼(SONY) DSC-RX100M5(RX100V)黑卡数码相机',3,6199,'全新黑卡第五代,火热开抢');

insert into tbl_item_1(`name` ,`categoryid`,`price`,`desc` ) values('海信(Hisense)LED55EC780UC 55英寸 曲面4K智能平板电视',4,4598,'55英寸曲面4K机皇!');

insert into tbl_item_1(`name` ,`categoryid`,`price`,`desc` ) values('苏泊尔无油烟炒锅PC32H2',1,599,'先领券再下单,超值!');

create table if not exists tbl_item_2(

`id` int(10) not null auto_increment,

`name` varchar(20) not null,

`categoryid` int(10) not null,

`price` double(6,2) not null,

`desc` varchar(20) ,

primary key (`id`),

key `categoryid` (`categoryid`)

)engine=myiasm default charset=utf8 auto_increment=1;

insert into tbl_item_2(`name` ,`categoryid`,`price`,`desc` ) values('三星 Galaxy S7 edge(G9350)4GB+32GB 雪晶白',1,3399,'Super AMOLED三星双曲面2K 屏,支持无线充电!');

insert into tbl_item_2(`name` ,`categoryid`,`price`,`desc` ) values('联想(Lenovo)拯救者R720',2,6399.00,'专业游戏键盘新模具全新设计!');

insert into tbl_item_2(`name` ,`categoryid`,`price`,`desc` ) values('Apple iPhone 7 Plus (A1661) 128G 黑色',1,6099,'全国不限流量任意刷,下单更享200M光纤0元购!');

insert into tbl_item_2(`name` ,`categoryid`,`price`,`desc` ) values('索尼(SONY) DSC-RX100M5(RX100V)黑卡数码相机',3,6199,'全新黑卡第五代,火热开抢');

insert into tbl_item_2(`name` ,`categoryid`,`price`,`desc` ) values('海信(Hisense)LED55EC780UC 55英寸 曲面4K智能平板电视',4,4598,'55英寸曲面4K机皇!');

insert into tbl_item_2(`name` ,`categoryid`,`price`,`desc` ) values('苏泊尔无油烟炒锅PC32H2',1,599,'先领券再下单,超值!');

经过mysql5.5.48版本测试,无论使用myisam还是innodb都无法使用到索引。

a9d52f17f380763b7c8aa66f2e98735f.png

下面这篇文章中提到mysql 5.7版本使用myisam时可以用到索引,推测可能是后续版本做了改进:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值