当前位置:网站首页>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要快。
边栏推荐
- Thoughts on a "01 knapsack problem" expansion problem
- 无限水平大理石游戏
- HCM 初学 ( 二 ) - 信息类型
- Geoffrey Hinton:我的五十年深度学习生涯与研究心法
- 栈题目:解析布尔表达式
- LED lighting used in health lighting
- First defined here occurs during QT compilation. Causes and Solutions
- OpenGL ES: (5) OpenGL的基本概念、OpenGL ES 在屏幕产生图片的过程、OpenGL管线(pipeline)
- Qt编写自定义控件-自绘电池
- Continue to learn MySQL
猜你喜欢

linux 关闭redis 进程 systemd+

On the first day of the new year, 3000 Apache servers went down

Crossing pie · pie pan + Mountain duck = local data management

Geoffrey Hinton: my 50 years of in-depth study and Research on mental skills

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

PLA不粘贴在床上:6个简单的解决方案

He struggled day and night to protect his data

Diagramme dynamique Excel

excel動態圖錶

FPGA - 7系列 FPGA内部结构之Clocking -01- 时钟架构概述
随机推荐
可动的机械挂钟
C language beginner level - realize the minesweeping game
DEV XPO对比之UOW
Ucosiii --- engineering transplantation
SystemVerilog学习-08-随机约束和线程控制
Multi label lsml for essay learning records
Send you through the data cloud
运行时候的导包搜索路径虽然pycharm中标红但不影响程序的执行
加密狗资料搜集
Pla ne colle pas sur le lit: 6 solutions simples
jdbc 数据库操作
Codeforces Round #803 (Div. 2)vp
Brief description of activation function
2022第八届中国国际“互联网+”大学生创新创业大赛产业命题赛道开启报名!
【文件系统】如何在ubi之上运行squashfs
Qt编写自定义控件-自绘电池
TiDB单机模拟部署生产环境集群(闭坑实践,亲测有效)
Build 2022 上开发者最应关注的七大方向主要技术更新
3D打印机穿线:5种简单的解决方案
2022.6.30-----leetcode. one thousand one hundred and seventy-five