当前位置:网站首页>MySQL中 in 和 exists 的区别
MySQL中 in 和 exists 的区别
2022-07-01 05:54:00 【明明就很安静】
MySQL中的in语句是把外表和内表作hash 连接,而exists语句是对外表作loop循环,每次loop循环再对内表进行查询。使用场景:
如果查询的两个表大小相当,那么用in和exists差别不大。
如果两个表中一个较小,一个是大表,则子查询表大的用exists,子查询表小的用in。
not in 和not exists:如果查询语句使用了not in,那么内外表都进行全表扫描,没有用到索引;而not extsts的子查询依然能用到表上的索引。所以无论那个表大,用not exists都比not in要快。
边栏推荐
猜你喜欢

这才是大学生必备软件 | 知识管理

论文学习记录随笔 多标签之GLOCAL

Huluer app help

无限水平大理石游戏

el-table 动态表头渲染 固定第一列 高度问题

Geoffrey Hinton:我的五十年深度学习生涯与研究心法

OpenGL es: (5) basic concepts of OpenGL, the process of OpenGL es generating pictures on the screen, and OpenGL pipeline

论文学习记录随笔 多标签之LSML

穿越派·派盘 + Mountain Duck = 数据本地管理

MySQL数据迁移遇到的一些错误
随机推荐
He struggled day and night to protect his data
Preliminary level of C language -- selected good questions on niuke.com
libpng12.so.0: cannot open shared object file: No such file or directory 亲测有效
bat操作ftp上传下载命令
关于一道01背包问题的·拓展题的思考
jdbc-连接池
ONEFLOW source code parsing: automatic inference of operator signature
为了保护自己的数据,他奋斗了一天一夜
Fragment upload and breakpoint resume
linux 关闭redis 进程 systemd+
穿越派 你的数据云行
Multi label lsml for essay learning records
PLA不粘贴在床上:6个简单的解决方案
Cjc8988 Low Power Stereo codec with 2 stereo headphone drivers
Build 2022 上开发者最应关注的七大方向主要技术更新
我从技术到产品经理的几点体会
Excel dynamic chart
Qt编写自定义控件-自绘电池
First defined here occurs during QT compilation. Causes and Solutions
OpenGL es: (4) detailed explanation of EGL API (Continued)