Postgres的scan filter 和 join filter 比较

本文探讨了Postgres执行计划中的scan filter和join filter的区别。scan filter源自where或having子句,而join filter源于ON子句,用于表间连接。在外连接中,join filter不会剔除行,但普通filter可以。举例说明了两者如何影响执行计划,并解释了左外连接的工作原理。
摘要由CSDN通过智能技术生成

在Postgres执行计划里面出现两种filter ,容易混淆,这里记录一下: 

 scan filter:   普通的过滤条件,一般来自与where ...; having ...子句中的条件。
 join filter:   多表联结的时候,表与表之间联结时候的过滤条件 ,来自于on子语 。需要注意的是:在外连接的时候,是不能过滤行的, 在内连接的的时候与普通的filter没有区别。

看下官方文档怎么说的:

When dealing with outer joins, you might see join plan nodes with both “Join Filter” and plain “Filter”

conditions attached. Join Filter conditions come from the outer join's ON clause, so a row that fails

the Join Filter condition could still get emitted as a null-extended row.But a plain Filter condition is

applied after the outer-join rules and so acts to remove rows unconditionally. In an inner join there is

no semantic difference between these types of filters.

举个例子:

create table test_left 
( id int,  name varchar(50) 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值