t1
让我们假设我们在and之间有一个连接t2
,如下所示:
select c1, ..., cn
from t1 join t2
on t1.fk = t2.k
join t3
on t2.fk = t3.k
where (some condition independent from t3)
哪里(some condition independent from t3)
可能有任何东西。现在,考虑这个查询:
select c1, ..., cn
from t1 join t2
on t1.fk = t2.k and (some condition independent from t3)
join t3
on t2.fk = t3.k
让我们假设t1
x t2
xt3
与join
条件一起产生 count1 行,而如果我们也按where
条件过滤,那么我们将有 count2 个记录,其中 count2 <= count1。
我想知道where
条件是针对所有 count1 行执行,还是仅针对 count2 行的子集执行?尽快将条件包含在 on 条件中而不是在查询末尾附加它们在性能方面更好吗?