数据仓库服务 GAUSSDB(DWS)-指定子查询不提升的hint:示例

时间:2024-07-01 10:52:16

示例

创建表t1、t2、t3:

1
2
3
create table t1(a1 int,b1 int,c1 int,d1 int);
create table t2(a2 int,b2 int,c2 int,d2 int);
create table t3(a3 int,b3 int,c3 int,d3 int);

原语句为:

1
explain select * from t3, (select a1,b2,c1,d2 from t1,t2 where t1.a1=t2.a2) s1 where t3.b3=s1.b2;

上述查询中,可以使用以下两种方式禁止子查询s1进行提升:

  • 方式一:
    1
    explain select /*+ no merge(s1) */ * from t3, (select a1,b2,c1,d2 from t1,t2 where t1.a1=t2.a2) s1 where t3.b3=s1.b2;
    
  • 方式二:
    1
    explain select * from t3, (select /*+ no merge */ a1,b2,c1,d2 from t1,t2 where t1.a1=t2.a2) s1 where t3.b3=s1.b2;
    

提升后效果:

support.huaweicloud.com/performance-dws/dws_10_0066.html