当前位置:网站首页>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要快。
边栏推荐
- SystemVerilog学习-09-进程间同步、通信和虚方法
- OpenGL ES: (2) OpenGL ES 与 EGL、GLSL的关系
- 3D printer threading: five simple solutions
- 2022.6.30-----leetcode. one thousand one hundred and seventy-five
- Advanced cross platform application development (III): online resource upgrade / hot update with uni app
- SystemVerilog学习-06-类的封装
- 论文学习记录随笔 多标签之LIFT
- 栈题目:解析布尔表达式
- LED lighting used in health lighting
- 为什么用葫芦儿派盘取代U盘?
猜你喜欢
随机推荐
QT write custom control - self drawn battery
Looking for high school student developers with similar interests
MySQL converts milliseconds to time string
SystemVerilog学习-07-类的继承和包的使用
jdbc 数据库操作
OpenGL ES: (1) OpenGL ES的由来 (转)
Don't put your notes and videos everywhere!
喊我们大学生个人云服务特供商
穿越派·派盘 + 思源笔记 = 私人笔记本
2022 年面向初学者的 10 大免费 3D 建模软件
运行时候的导包搜索路径虽然pycharm中标红但不影响程序的执行
HCM 初学 ( 一 ) - 简介
数据库问题,如何优化Oracle SQL查询语句更快,效率更高
云盘里资料被和谐了,怎么办?
On the first day of the new year, 3000 Apache servers went down
论文学习记录随笔 多标签之GLOCAL
srpingboot security demo
Code shoe set - mt3149 · and - the data is not very strong. Violent pruning can deceive AC
Dear pie users, I want to confess to you!
TiDB单机模拟部署生产环境集群(闭坑实践,亲测有效)








