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';
相关推荐
FfHUCisI25 分钟前
Golang 数据库连接池深度调优
android·数据库·golang
我不会插花弄玉37 分钟前
2.库的操作【由浅入深-MySQL】
数据库·mysql
viskaz1 小时前
1-向量数据库概览
数据库·embedding
这个DBA有点耶2 小时前
实时数据集成工具选型2026:从CDC到数据同步的完整指南
数据库·数据挖掘·dba
__zRainy__2 小时前
Node系列 · ORM:Sequelize 简介
数据库·后端·node.js
鸽芷咕2 小时前
达梦VS金仓选型实录:别只比TPC-C,迁移工具链才是项目成败的关键
数据库
King of fraud3 小时前
Linux 下 MySQL 基础操作:创建用户、数据库与权限管理实战
linux·数据库·mysql
努力的小雨3 小时前
sys_basebackup 适合什么场景,先看恢复目标
数据库
这个DBA有点耶3 小时前
Redis大key“根治”指南:拆分策略与数据结构选型
数据库·mysql·架构
程序员与背包客_CoderZ4 小时前
高性能分布式KV存储引擎RocksDB入门与C/C++编码实战
c语言·开发语言·数据库·c++·分布式·分布式数据库·rocksdb