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';
相关推荐
poemyang2 小时前
十年大厂员工终明白:MySQL性能优化的尽头,是对B+树的极致理解
mysql·pagecache·顺序i/o·局部性原理·b tree·b+ tree
wyiyiyi4 小时前
【Web后端】Django、flask及其场景——以构建系统原型为例
前端·数据库·后端·python·django·flask
天宇_任4 小时前
Mysql数据库迁移到GaussDB注意事项
数据库·mysql·gaussdb
xiep14383335107 小时前
Ubuntu 安装带证书的 etcd 集群
数据库·etcd
Java小白程序员8 小时前
Spring Framework:Java 开发的基石与 Spring 生态的起点
java·数据库·spring
老虎06278 小时前
数据库基础—SQL语句总结及在开发时
数据库·sql·oracle
爱掘金的土拨鼠10 小时前
国产化dm数据库锁表解锁
数据库
花花无缺10 小时前
MySQL 的存储引擎-InnoDB 和 MyISAM的对比
mysql
苏琢玉10 小时前
如何让同事自己查数据?写一个零依赖 PHP SQL 查询工具就够了
mysql·php
庖丁解java10 小时前
N个Utils
数据库