当前位置:网站首页>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要快。
边栏推荐
- Vscode function annotation / file header annotation shortcut
- FPGA - 7系列 FPGA内部结构之Clocking -01- 时钟架构概述
- srpingboot security demo
- Beauty of Mathematics - Application of Mathematics
- OpenGL es: (1) origin of OpenGL es (transfer)
- Oracle create user + Role
- 如何添加葫芦儿派盘
- OpenGL ES: (1) OpenGL ES的由来 (转)
- excel动态图表
- This is the necessary software for college students 𞓜 knowledge management
猜你喜欢

Cjc8988 Low Power Stereo codec with 2 stereo headphone drivers

为什么用葫芦儿派盘取代U盘?

What if the data in the cloud disk is harmonious?

OpenGL ES: (5) OpenGL的基本概念、OpenGL ES 在屏幕产生图片的过程、OpenGL管线(pipeline)

SystemVerilog学习-10-验证量化和覆盖率

Infinite horizontal marble game

Preliminary level of C language -- selected good questions on niuke.com

excel高级绘图技巧100讲(一)-用甘特图来展示项目进度情况

ONEFLOW source code parsing: automatic inference of operator signature

云盘里资料被和谐了,怎么办?
随机推荐
[medical segmentation] u2net
El tooltip in the table realizes line breaking display
restframework-simpleJWT重写认证机制
如何添加葫芦儿派盘
Codeforces Round #803 (Div. 2)vp
Know the future of "edge computing" from the Nobel prize!
LED lighting used in health lighting
Excel dynamic chart
Looking for high school student developers with similar interests
It's not that you have a bad mind, but that you haven't found the right tool
OpenGL es: (2) relationship between OpenGL es, EGL and glsl
Enter an expression (expressed as a string) and find the value of this expression.
Dear pie users, I want to confess to you!
解决麒麟V10上传文件乱码问题
【知识点总结】卡方分布,t分布,F分布
加密狗资料搜集
Beauty of Mathematics - Application of Mathematics
[note] e-commerce order data analysis practice
This is the necessary software for college students 𞓜 knowledge management
MySQL converts milliseconds to time string