LightDB支持 no_expand hint【24.1】【oracle兼容】

LightDB 从 24.1 开始支持 oracle no_expand hint。
no_expand hint 用于取消OR-expansion优化,不进行OR-expansion优化。

OR-expansion

在 Oracle 中 优化器会基于cost 优化带析取的查询块(OR), 会拆分这个查询块为多个查询块,并用union all 组合起来, 这样就可以利用索引, 并且可以并发执行查询块。

使用示例

由于 LightDB 目前不支持 OR-expansion 优化,因此 no_expand hint 就是默认的行为, 一定会生效。

create table t_no_expand1(key1 int, key2 int);
create table t_no_expand2(key1 int, key2 int);

lightdb@postgres=# EXPLAIN (COSTS false) select * from t_no_expand1 where exists (select * from t_no_expand2 where key1= 1 or key2=1) or key1 =10;
                  QUERY PLAN                  
----------------------------------------------
 Seq Scan on t_no_expand1
   Filter: ($0 OR (key1 = 10))
   InitPlan 1 (returns $0)
     ->  Seq Scan on t_no_expand2
           Filter: ((key1 = 1) OR (key2 = 1))
(5 rows)

lightdb@postgres=# EXPLAIN (COSTS false) select /*+no_expand*/ * from t_no_expand1 where exists (select * from t_no_expand2 where key1= 1 or key2=1) or key1 =10;
LOG:  lt_hint_plan:
used hint:
no_expand
not used hint:
duplication hint:
error hint:

                  QUERY PLAN                  
----------------------------------------------
 Seq Scan on t_no_expand1 @"lt#0"
   Filter: ($0 OR (key1 = 10))
   InitPlan 1 (returns $0)
     ->  Seq Scan on t_no_expand2
           Filter: ((key1 = 1) OR (key2 = 1))
(5 rows)

lightdb@postgres=# EXPLAIN (COSTS false) select * from t_no_expand1 where exists (select /*+no_expand*/ * from t_no_expand2 where key1= 1 or key2=1) or key1 =10;
LOG:  lt_hint_plan:
used hint:
no_expand
not used hint:
duplication hint:
error hint:

                  QUERY PLAN                  
----------------------------------------------
 Seq Scan on t_no_expand1 @"lt#1"
   Filter: ($0 OR (key1 = 10))
   InitPlan 1 (returns $0)
     ->  Seq Scan on t_no_expand2 @"lt#0"
           Filter: ((key1 = 1) OR (key2 = 1))
(5 rows)

lightdb@postgres=# EXPLAIN (COSTS false) select /*+no_expand(@qb)*/ * from t_no_expand1 where exists (select/*+qb_name(qb)*/ * from t_no_expand2 where key1= 1 or key2=1) or key1 =10;
LOG:  lt_hint_plan:
used hint:
no_expand(@qb)
not used hint:
duplication hint:
error hint:

                  QUERY PLAN                  
----------------------------------------------
 Seq Scan on t_no_expand1 @"lt#0"
   Filter: ($0 OR (key1 = 10))
   InitPlan 1 (returns $0)
     ->  Seq Scan on t_no_expand2 @qb
           Filter: ((key1 = 1) OR (key2 = 1))
(5 rows)

相关推荐

  1. LightDB支持 no_expand hint【24.1】【oracle兼容

    2024-03-11 15:14:03       40 阅读
  2. LightDB24.1 oracle_fdw支持服务端GBK编码

    2024-03-11 15:14:03       49 阅读
  3. LightDB24.1ECPG支持EXEC ORACLE OPTION语法

    2024-03-11 15:14:03       41 阅读
  4. LightDB - 支持 last_day 函数[mysql兼容]

    2024-03-11 15:14:03       57 阅读
  5. LightDB - 支持substring_index 函数[mysql兼容]

    2024-03-11 15:14:03       52 阅读
  6. LightDB24.1 pro*c 支持EXEC ORACLE OPTION (CHAR_MAP=STRING)

    2024-03-11 15:14:03       25 阅读
  7. LightDB - 支持 curdate, current_date 函数[mysql兼容]

    2024-03-11 15:14:03       60 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-11 15:14:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-11 15:14:03       101 阅读
  3. 在Django里面运行非项目文件

    2024-03-11 15:14:03       82 阅读
  4. Python语言-面向对象

    2024-03-11 15:14:03       91 阅读

热门阅读

  1. 嵌入式学习35-网络通信UDP聊天及TCP

    2024-03-11 15:14:03       40 阅读
  2. ARM GNU 汇编 “每日读书“

    2024-03-11 15:14:03       40 阅读
  3. flink是什么

    2024-03-11 15:14:03       36 阅读
  4. 使用docker搭建s-pdf

    2024-03-11 15:14:03       45 阅读
  5. 《Effective Modern C++》- 极精简版 30-35条

    2024-03-11 15:14:03       44 阅读
  6. 力扣爆刷第91天之hot100五连刷41-45

    2024-03-11 15:14:03       46 阅读
  7. 【Django】聚合查询

    2024-03-11 15:14:03       42 阅读
  8. 数据的处理包括哪些内容

    2024-03-11 15:14:03       37 阅读
  9. TREC 2023 Deep Learning Track Guidelines

    2024-03-11 15:14:03       35 阅读
  10. Django路由层

    2024-03-11 15:14:03       39 阅读