当前位置:网站首页>解析数仓lazyagg查询重写优化
解析数仓lazyagg查询重写优化
2022-06-25 15:56:00 【InfoQ】
一、Lazy Agg重写规则
SELECT t2.b, sum(cc) FROM (SELECT b, sum(c) AS cc FROM t1 GROUP BY b) AS s, t2 WHERE s.b=t2.b GROUP BY t2.b;
SELECT t2.b, sum(cc) FROM (SELECT b, c AS cc FROM t1) AS s, t2 WHERE s.b=t2.b GROUP BY t2.b;二、GaussDB(DWS) lazyagg优化


三、lazyagg优化规格
- 支持子查询为单一聚集查询或包含聚集子集合操作的查询。集合操作仅支持UNION ALL,可对部分分支子查询进行聚集运算消除。子查询需为JOIN表之一(不在TargetList、Where子句等其他位置)。
- 支持若外部查询的所有Agg参数列包含于其某个子查询的Agg函数列,则可对该子查询的聚集运算进行消除。
- 支持所有消除子查询聚集运算后结果正确的聚集函数种类。聚集函数种类结果正确性见下表:

- 不支持消除的Agg函数类型。
- 子查询中包含其它条件或算子,会导致重写后结果错误,例如HAVING、window agg、LIMIT、OFFSET、AP function、distinct、recursive等。
- 外层Agg参数列、GROUP BY列或JOIN列中包含volatile函数,如random、timeofday等。
- 子查询Agg函数外、外部查询Agg函数内有其他表达式或函数操作,如子查询Agg函数列为sum+1、max+max(d),外部查询Agg函数列为sum(cc+1)等。
- 外部查询的JOIN列、GROUP BY列或其它条件中包含子查询Agg函数列。
- 子查询在LEFT JOIN、RIGHT JOIN的inner边或FULL JOIN中,且子查询Agg函数为count,外部查询Agg函数为sum的。
四、结语
边栏推荐
猜你喜欢

What exactly is a handler

Understand the execution sequence of try catch finally in one diagram

Beginner bug set

GridLayout evenly allocate space

Dino: Detr with improved detecting anchor boxes for end to end object detection

What plug-ins are available for vscade?

【機器學習】基於多元時間序列對高考預測分析案例

数字经济时代文化消费新特征

Kettle表输入组件精度丢失的问题

Learning notes of rxjs takeuntil operator
随机推荐
有哪些新手程序员不知道的小技巧?
10 Super VIM plug-ins, I can't put them down
Built in function globals() locals()
Function and implementation of closures
Detailed explanation of IVX low code platform series -- Overview (I)
Mysql database multi table query
WPF开发随笔收录-心电图曲线绘制
Servlet details
炮打司令部,别让一个UI框架把你毁了
What is the NFT digital collection?
GridLayout evenly allocate space
What are some tricks that novice programmers don't know?
About: encryption and decryption of rsa+aes data transmission [chapter], project practice (special summary)
Rxjs TakeUntil 操作符的学习笔记
赫尔辛基交通安全改善项目部署Velodyne Lidar智能基础设施解决方案
DDD概念复杂难懂,实际落地如何设计代码实现模型?
[100 questions of Blue Bridge Cup intensive training] scratch command mobile Blue Bridge Cup scratch competition special prediction programming question intensive training simulation exercise question
In the wechat environment, H5 jumps to the specified page of the applet
Mt60b1g16hc-48b:a micron memory particles FBGA code d8bnk[easy to understand]
Based on neural tag search, the multilingual abstracts of zero samples of Chinese Academy of Sciences and Microsoft Asiatic research were selected into ACL 2022