当前位置:网站首页>MySQL性能优化_小表驱动大表
MySQL性能优化_小表驱动大表
2022-08-03 15:38:00 【涛歌依旧fly】
https://blog.csdn.net/CSDN_FlyYoung/article/details/123072418
MySQL性能优化_小表驱动大表
1. 什么是小表驱动大表 ?
2. 为什么要用小表驱动大表 ?
类似循环嵌套
for(int i=5;.......)
{
for(int j=1000;......)
{
}
}
12345
如果小的循环在外层,对于数据库连接来说就只连接5次,进行5000次操作;如果1000在外,则需要进行1000次数据库连接,从而浪费资源,增加消耗。这就是为什么要小表驱动大表。
3. 用法
join
MySQL高级知识(五)——索引分析
mysql leftjoin 大表在外_小表驱动大表
in 与 exists
MySQL高级知识(十六)——小表驱动大表
MySQL关联查询时,我们为什么建议小表驱动大表?
Mysql优化原则_小表驱动大表IN和EXISTS的合理利用
数据准备
案例演示
当B表的数据集小于A表数据集时,用in优于exists。
当A表的数据集小于B表的数据集时,用exists优于in。
结论
in后面跟的是小表,exists后面跟的是大表(in 小, exists 大)
1) 当B表数据集小于A表数据集时,用in优于exists。
select *from tb_emp_bigdata A where A.deptno in (select B.deptno from tb_dept_bigdata B)
1
2) 当A表数据集小于B表数据集时,用exists优于in。
select *from tb_dept_bigdata A where A.deptno in(select B.deptno from tb_emp_bigdata B);
1
边栏推荐
猜你喜欢
深度学习——安装CUDA以及CUDNN实现tensorflow的GPU运行
Optimal Power Flow (OPF) for High Voltage Direct Current (HVDC) (Matlab code implementation)
【数据库数据恢复】SqlServer数据库无法读取的数据恢复案例
【码蹄集新手村600题】将一个函数定义宏
Js array method is summarized
【899. 有序队列】
[Code Hoof Set Novice Village 600 Questions] Define a function as a macro
问题6:下拉框测试点
MATLAB gcf figure save image with black background/transparent background
nodeJs--跨域
随机推荐
请问下阿里云全托管flink能执行两条flink sql命令么?
新一代网状网协议T-Mesh无线通信技术优势介绍
30W 2C(JD6606S + FP6652X2)BOM
劲爆!协程终于来了!线程即将是过去式
问题1:批量测试(正式测试)之前应该怎么做?
DC-DC 2C(40W/30W) JD6606SX2退功率应用
一文搞懂$_POST和php://input的区别
After the cnpm installation is successful, the prompt is not an internal and external command, nor is it a runnable command solution
devops-3:Jenkins增加静态节点
49 万奖金等你来拿!第四届实时计算 Flink 挑战赛启动,Beyond Stream Processing!
程序员面试必备PHP基础面试题 – 第十八天
Research on power flow in DC microgrid based on Newton's method (Matlab code implementation)
How Navicat connects to MySQL on a remote server
【网络结构】VGG
MATLAB gcf图窗保存图像,黑色背景/透明背景
JS handwritten call apply bind (detailed) (interview)
JD6606SP5_JD6606SSP_JD6606SASP_JD6621W7百盛新纪元授权代理商
程序员面试必备PHP基础面试题 – 第二十天
Go Go 简单的很,标准库之 fmt 包的一键入门
高可用版 主数据库数据结构改变 备数据库会自动改变吗