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';
相关推荐
程序员小白条5 小时前
0经验如何找实习?
java·开发语言·数据结构·数据库·链表
liulilittle5 小时前
C++ 浮点数封装。
linux·服务器·开发语言·前端·网络·数据库·c++
郭涤生5 小时前
QT 架构笔记
java·数据库·系统架构
韩立学长5 小时前
基于Springboot流浪动物领养网站0kh2iyb4(程序、源码、数据库、调试部署方案及开发环境)系统界面展示及获取方式置于文档末尾,可供参考。
数据库·spring boot·后端
DBA小马哥6 小时前
Oracle迁移到金仓数据库:完整迁移步骤与兼容性优化实战
数据库·oracle·国产化平替
@nengdoudou6 小时前
KStudio 客户端无法访问 KES 数据库服务器的指定 IP / 端口
数据库
R.lin7 小时前
windows MySQL解压版安装教程
windows·mysql·adb
宋军涛7 小时前
记一次Sqlserver数据库存储过程调用导致的连接池耗尽事件
数据库
前端小臻7 小时前
MySQL 错误 1005 (errno: 150) 深度解析与解决方案
数据库·mysql
魔镜前的帅比7 小时前
向量数据库原理
数据库·人工智能