当前位置:网站首页>解析数仓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的。
四、结语
边栏推荐
猜你喜欢

Navicat premium 15 for MAC (database development tool) Chinese version

心楼:华为运动健康的七年筑造之旅

GO语言-什么是临界资源安全问题?

Lecun predicts AgI: big model and reinforcement learning are both ramps! My "world model" is the new way

【机器学习】基于多元时间序列对高考预测分析案例

【效率】又一款笔记神器开源了!

论文笔记:LBCF: A Large-Scale Budget-Constrained Causal Forest Algorithm

DOM event flow, event delegate

Helsinki traffic safety improvement project deploys velodyne lidar Intelligent Infrastructure Solution

Nsurlsession learning notes (III) download task
随机推荐
What can NFT metauniverse development do?
Navicat premium 15 for MAC (database development tool) Chinese version
GO语言-锁操作
About: encryption and decryption of rsa+aes data transmission [chapter], project practice (special summary)
Flutter textfield setting can input multiple lines
Activation and value transfer of activity
Common APIs and exception mechanisms
Swift responsive programming
Xinlou: Huawei's seven-year building journey of sports health
报错:homebrew-core is a shallow clone
uniapp实现图片(单张/多张)预览
Day_ fourteen
[Third Party framework] retrofit2 (2) - add point configuration of network access framework
Deep learning pytorch cifar10 dataset training "suggestions collection"
Stop "outsourcing" Ai models! The latest research finds that some "back doors" that undermine the security of machine learning models cannot be detected
Alvaria宣布客户体验行业资深人士Jeff Cotten担任新首席执行官
Div element
_ 19_ IO stream summary
Day_ fifteen
[problem solving] dialogfragment can not be attached to a container view