MySQL索引查询(EXPLAIN UNION)

sql 复制代码
explain select * from city where ID>500 limit 10;

explain select `Name`,CountryCode,District from city where District='Utrecht';



explain select `Name`,CountryCode,District from city where ID=5;

explain select `Name`,CountryCode,District from city where ID<5;

explain select `Name`,CountryCode,District from city where CountryCode like 'NL_';

explain select `Name`,CountryCode,District from city where CountryCode='NLD' OR CountryCode='PHL';

explain select `Name`,CountryCode,District from city where CountryCode in('NLD','PHL');

explain select * from city where ID>500 limit 10;

explain select `Name`,CountryCode,District from city where District='Utrecht';

explain select `Name`,CountryCode,District from city where ID=5;

explain select `Name`,CountryCode,District from city where ID<5;

explain select `Name`,CountryCode,District from city where CountryCode like 'NL_';

explain select `Name`,CountryCode,District from city where CountryCode='NLD' OR CountryCode='PHL';

explain select `Name`,CountryCode,District from city where CountryCode in('NLD','PHL');

性能最快的方法是union联合查询

sql 复制代码
explain 
select `Name`,CountryCode,District from city where CountryCode='NLD'
union
select `Name`,CountryCode,District from city where CountryCode='PHL';
相关推荐
马克学长2 小时前
SSM面向乡村振兴服务的产教融合服务平台521gh(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·乡村振兴·ssm 框架·服务平台
u***27612 小时前
C#数据库操作系列---SqlSugar完结篇
网络·数据库·c#
Y***K4343 小时前
MySQL网站
数据库·mysql
q***44813 小时前
postgresql链接详解
数据库·postgresql
菜鸟‍3 小时前
【后端学习】MySQL数据库
数据库·后端·学习·mysql
污斑兔3 小时前
腾讯云 CloudBase 数据库 CRUD 完整指南
数据库·云计算·腾讯云
tuokuac4 小时前
批量新增操作为什么要加@Transactional注解
数据库
q***9946 小时前
Redis的Spring配置
数据库·redis·spring
S***y3966 小时前
MySQL视频
数据库·mysql
周杰伦fans7 小时前
[特殊字符] 代理模式超详细讲解 ——.NET
数据库·c#·代理模式