lightdb21.3-新增优化器提示no_merge

Posted 紫无之紫

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lightdb21.3-新增优化器提示no_merge相关的知识,希望对你有一定的参考价值。

lightdb21.3-新增优化器提示no_merge

新增no_merge hint用来建议优化器不提升子查询,即子查询运行出结果集再和外层查询的其它结果集进行关联操作 。

一般适用于子查询结果集很小等情况,如果此时提升子查询会导致查询变慢。

具体用法如下:

postgres=# EXPLAIN (COSTS false) select * from t1, (select /*+no_merge*/t2.id from t2,t3) tt where t1.id=tt.id;
    LOG:  pg_hint_plan:
    used hint:
    no_merge
    not used hint:
    duplication hint:
    error hint:

    QUERY PLAN                
    ------------------------------------------
    Hash Join
    Hash Cond: (t2.id = t1.id)
    ->  Nested Loop
    ->  Seq Scan on t2 @"lt#0"
    ->  Materialize
    ->  Seq Scan on t3 @"lt#0"
    ->  Hash
    ->  Seq Scan on t1 @"lt#1"
    (8 rows)


postgres=# EXPLAIN (COSTS false) select/*+ no_merge(tt)*/ * from t1, (select t2.id from t2,t3) tt where t1.id=tt.id;
    LOG:  pg_hint_plan:
    used hint:
    no_merge(tt@lt#0)
    not used hint:
    duplication hint:
    error hint:

    QUERY PLAN             
    ------------------------------------
    Hash Join
    Hash Cond: (t2.id = t1.id)
    ->  Nested Loop
    ->  Seq Scan on t2
    ->  Materialize
    ->  Seq Scan on t3
    ->  Hash
    ->  Seq Scan on t1 @"lt#0"
    (8 rows)

postgres=# 


postgres=# EXPLAIN (COSTS false) select/*+ no_merge(@qb)*/ * from t1, (select/*+qb_name(qb)*/ t2.id from t2,t3) tt where t1.id=tt.id;
    LOG:  pg_hint_plan:
    used hint:
    no_merge(@qb)
    not used hint:
    duplication hint:
    error hint:

    QUERY PLAN              
    --------------------------------------
    Hash Join
    Hash Cond: (t2.id = t1.id)
    ->  Nested Loop
    ->  Seq Scan on t2 @qb
    ->  Materialize
    ->  Seq Scan on t3 @qb
    ->  Hash
    ->  Seq Scan on t1 @"lt#0"
    (8 rows)

postgres=# 

以上是关于lightdb21.3-新增优化器提示no_merge的主要内容,如果未能解决你的问题,请参考以下文章

lightdb21.3-支持语句级hint

lightdb21.3-支持语句级hint

lightdb22.1新特性-新增多种优化器提示

lightdb22.4-新增优化器提示cardinality 和ordered_predicates

lightdb22.4-新增优化器提示cardinality 和ordered_predicates

lightdb22.1新特性-分布式下支持使用优化器提示