云数据库 GAUSSDB-案例:改写SQL消除子查询:优化说明

时间:2024-11-02 18:46:36

优化说明

此优化的核心就是消除子查询。分析业务场景发现a.ca_address_sk不为null,那么从SQL语义出发,可以等价改写SQL为:

1
2
3
4
5
select 
count(*) 
from customer_address_001 a4, customer_address_001 a
where a4.ca_address_sk = a.ca_address_sk
group by  a.ca_address_sk;

为了保证改写的等效性,在customer_address_001. ca_address_sk加了not null约束。

support.huaweicloud.com/distributed-devg-v3-gaussdb/gaussdb-12-0310.html