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执行计划固化的原理与稳定性工程
数据库·sql优化·执行计划
TDengine (老段)4 小时前
TDengine IDMP 功能点—数据接入
大数据·数据库·物联网·时序数据库·tdengine·涛思数据
索西引擎5 小时前
MySQL 进阶:视图、存储过程、存储函数与触发器
数据库·mysql
bksczm6 小时前
InnoDB 通用表空间与临时表空间详解
大数据·数据库·mysql
靠沿6 小时前
MySQL数据库进阶——存储过程和触发器
java·数据库·mysql
码少女7 小时前
MySQL--库与表的增删改查基础
java·数据库·mysql
Eyfcom7 小时前
〖物流 SaaS 实战 02〗SaaS 租户的计费与订阅模型:从“一锤子买卖”到“按需订阅”
linux·服务器·数据库·快递系统·物流saas实战
打工的小王8 小时前
postgresql和mysql对比
数据库·mysql·postgresql
数据库急诊室_阿哲9 小时前
一次割接后的性能复核记录:基线、样本、回滚点
运维·数据库·dba
保利威视频SaaS小张10 小时前
企业直播接入笔记 12|企业内训直播怎么做签到和学时统计,防挂机这件事比想象中难
java·前端·数据库·笔记·视频云·polvy·polyv