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';
相关推荐
麦麦大数据39 分钟前
J009 美食推荐可视化大数据系统vue+springboot
vue.js·spring boot·mysql·推荐算法·美食·可视化分析·沙箱支付
菜鸟笔记本1 小时前
linux设置定时备份mysql数据
linux·mysql·oracle
千寻技术帮1 小时前
10347_基于Springboot的新疆旅游管理系统
spring boot·mysql·旅游·在线旅游
施嘉伟1 小时前
一次生产环境 SQL 不走索引的排查过程
数据库·sql
踏浪无痕1 小时前
SQLInsight:从JDBC底层到API调用的零侵入SQL监控方案
数据库·后端·开源
小宇的天下2 小时前
Calibre nmDRC Results(19-1)
服务器·数据库·oracle
Web项目开发2 小时前
Mysql创建索引的SQL脚本,复制粘贴即可使用
数据库·sql·mysql
晴天¥3 小时前
Oracle如何在DBeaver上进行登录
数据库·oracle
2301_800256113 小时前
事务处理-同步与调度-两阶段锁-隔离级别
数据库·oracle
小罗和阿泽3 小时前
MySql数据库系列 数据库基础操作
数据库·mysql