当前位置:网站首页>sql优化(五):表连接
sql优化(五):表连接
2022-07-16 16:24:00 【我爱夜来香A】
一、嵌套循环(NESTED LOOPS)
***算法:驱动表返回一行数据,通过连接列传值给被驱动表,驱动表返回多少行,被驱动表就要被扫描多少次***
- 被驱动表必须走索引。如果被驱动表的连接列没在索引中,那么被驱动表只能走全表扫描,而且是反复多次全表扫描。当被驱动表很大的时候,sql就执行不出结果
- 被驱动表走索引只能走index unique scan或者index range scan,不能走table access
full,不能走index full scan,不能走index skip scan,也不能走index fast full scan - 两表返回少量数据才能走嵌套循环。如果两表关联返回100万条数据,那么被驱动表走索引就会返回一百万次回表。回表一般是单块读,这个时候sql性能极差
- 当两表为外关联的时候,如果执行计划是嵌套循环连接,驱动表只能是主表,使用hint也不行
select /*+ use_nl(e,d) leading(d) */ *
from<边栏推荐
- 在四线城市生活,拿一线城市工资,是种怎样的体验?
- Struct & Class & closure encapsulation in swift
- Anaconda installation (very detailed)
- [wechat applet] page configuration, network data request
- tensorflow极速入门
- Web. Set the file upload size limit and request data stream size settings in config.
- 内存函数的介绍及模拟实现
- SFF1602-MHCHXM超快恢复二极管SFF1602
- PHP-配置(Thinkphp 5)
- Logs issue 2022/07/16 | Li Jia, Hong Kong University of science and technology: Rethinking graph anomaly detection - what kind of graph neural network do we need?
猜你喜欢

RizomUV展UV使用记要

PHP read XML file

Typora drawing

Dynamic parameter transfer of PHP for tag end attribute (ThinkPHP)

Code forces round # 807 (DIV. 2) a - - D

Sff1602-mhchxm ultrafast recovery diode sff1602

"Daily practice, happy water problem" 1252 Number of odd value cells

手撕ORM(泛型+注解+反射)

Windwos常用命令(学习记录)

Win11鼠标动不了如何恢复?Win11鼠标动不了恢复的方法
随机推荐
Sff1602-mhchxm ultrafast recovery diode sff1602
内存函数的介绍及模拟实现
3.3. VGG_ model
OKALEIDO:我们为何如此看好多媒体NFT板块?
2022 network planning designer examination outline
Arbre DS - AVL de haut niveau
"Building a secure and optimized Wan"
[tools] visual studio keymap
Unity 打字机效果计时器实现和DOTween实现(笔记)
Analysis of real questions and answers of online planning designers in November 2021
What kind of experience is it to live in the fourth tier cities and earn wages in the first tier cities?
JMeter 21 day clock in day06
Several systems commonly used by servers
[tool usage] clion keymap
5道String高频面试题,拿捏String底层原理!
分享不同,精彩纷呈 | 开发者说·DTalk 年中鉴赏
电脑word文档页眉的横线怎么去掉
Dynamic loading problem of PHP include tag file attribute (ThinkPHP)
[multithreading] lock optimization mechanism in synchronized (biased lock - & gt; lightweight lock - & gt; heavyweight lock)
[MySQL] common commands and summary of "MySQL must know and know"