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 小时前
SQL进阶之旅 Day 21:临时表与内存表应用
sql·mysql·postgresql·database·temporary-table·memory-table·sql-optimization
敖云岚2 小时前
【Redis】分布式锁的介绍与演进之路
数据库·redis·分布式
LUCIAZZZ3 小时前
HikariCP数据库连接池原理解析
java·jvm·数据库·spring·springboot·线程池·连接池
我在北京coding3 小时前
300道GaussDB(WMS)题目及答案。
数据库·gaussdb
小Tomkk3 小时前
阿里云 RDS mysql 5.7 怎么 添加白名单 并链接数据库
数据库·mysql·阿里云
明月醉窗台4 小时前
qt使用笔记二:main.cpp详解
数据库·笔记·qt
沉到海底去吧Go5 小时前
【图片自动识别改名】识别图片中的文字并批量改名的工具,根据文字对图片批量改名,基于QT和腾讯OCR识别的实现方案
数据库·qt·ocr·图片识别自动改名·图片区域识别改名·pdf识别改名
老纪的技术唠嗑局5 小时前
重剑无锋,大巧不工 —— OceanBase 中的 Nest Loop Join 使用技巧分享
数据库·sql
未来之窗软件服务6 小时前
JAVASCRIPT 前端数据库-V6--仙盟数据库架构-—-—仙盟创梦IDE
数据库·数据库架构·仙盟创梦ide·东方仙盟·东方仙盟数据库
寒山李白6 小时前
MySQL复杂SQL(多表联查/子查询)详细讲解
sql·mysql·子查询·多表联查