惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
N
News and Events Feed by Topic
SecWiki News
SecWiki News
T
The Exploit Database - CXSecurity.com
S
Security @ Cisco Blogs
H
Heimdal Security Blog
Security Latest
Security Latest
T
Threatpost
V2EX - 技术
V2EX - 技术
C
Cybersecurity and Infrastructure Security Agency CISA
GbyAI
GbyAI
The Last Watchdog
The Last Watchdog
Recent Announcements
Recent Announcements
P
Privacy International News Feed
K
Kaspersky official blog
P
Proofpoint News Feed
L
LangChain Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Threat Research - Cisco Blogs
博客园_首页
T
Tor Project blog
M
MIT News - Artificial intelligence
The Hacker News
The Hacker News
The GitHub Blog
The GitHub Blog
月光博客
月光博客
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
F
Full Disclosure
MyScale Blog
MyScale Blog
The Register - Security
The Register - Security
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
Cyberwarzone
Cyberwarzone
L
LINUX DO - 最新话题
量子位
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
O
OpenAI News
T
The Blog of Author Tim Ferriss
S
Schneier on Security
小众软件
小众软件
The Cloudflare Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Know Your Adversary
Know Your Adversary
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
Lohrmann on Cybersecurity
Vercel News
Vercel News

博客园 - .net学习交流

Oracle profile详解 ORACLE使用JOB定时备份数据库 干掉标记为KILLED的session Oracle直方图详解(转) Export/Import DataPump Parameter QUERY - How to Specify a Query 一个完整的RMAN备份脚本 Oracle 10g的新特性flashback IBM AIX V5.3 磁盘存储管理 跨平台表空间传输(摘自eygle《循序渐进Oracle》) ORACLE EXP/IMP的使用详解 定义可延迟(deferrable)的约束 - .net学习交流 - 博客园 RMAN命令详解 Oracle中使用可传输表空间备份数据 一致性读(Consistent Reads)与buffer cache Oracle 中使用 fetch bulk collect into 批量效率的读取游标数据 oracle 游标属性 sql%found sql%notfound sql%rowcount 在存储过程中指定回滚段 EXP-00003: 未找到段 (11,419) 的存储定义解决方法 AIX上设置LOCK_SGA=TRUE
很容易理解的IN和EXISTS区别
.net学习交流 · 2009-05-21 · via 博客园 - .net学习交流

在ASKTOM的讲解:
Well, the two are processed very very differently.

Select * from T1 where x in ( select y from T2 )

is typically processed as:

select *
from t1, ( select distinct y from t2 ) t2
where t1.x = t2.y;

The subquery is evaluated, distinct'ed, indexed (or hashed or sorted) and then
joined to the original table -- typically.


As opposed to

select * from t1 where exists ( select null from t2 where y = x )

That is processed more like:


for x in ( select * from t1 )
loop
if ( exists ( select null from t2 where y = x.x )
then
OUTPUT THE RECORD
end if
end loop

It always results in a full scan of T1 whereas the first query can make use of
an index on T1(x).


So, when is where exists appropriate and in appropriate?

Lets say the result of the subquery
( select y from T2 )

is "huge" and takes a long time. But the table T1 is relatively small and
executing ( select null from t2 where y = x.x ) is very very fast (nice index on
t2(y)). Then the exists will be faster as the time to full scan T1 and do the
index probe into T2 could be less then the time to simply full scan T2 to build
the subquery we need to distinct on.


Lets say the result of the subquery is small -- then IN is typicaly more
appropriate.


If both the subquery and the outer table are huge -- either might work as well
as the other -- depends on the indexes and other factors.