You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2019/12/24 09:48:35 UTC

[GitHub] [incubator-doris] EmmyMiao87 edited a comment on issue #2101: 支持物化视图

EmmyMiao87 edited a comment on issue #2101: 支持物化视图
URL: https://github.com/apache/incubator-doris/issues/2101#issuecomment-561539438
 
 
   # 详细设计
   
   ## 名词解释
   1. Materialized Views: 简称 MVs,物化视图。
   
   ## 查询选择最优 MVs
   当前选择 MVs 的问题:
   
   1. 只有声明在第一位的表才有可能打开 PreAgg,如果表不声明在第一位,则一定不打开 PreAgg。只能覆盖特定的某些 Query。
   2. 比较聚合方式,和比较列对应关系相互分隔。PreAgg 只比较和base表的聚合方式,不比较 Rollup 表和 Query 列对应关系,打开 PreAgg 也可能无法选中 Rollup 表。
   
   
   *暂定不重写 Query,依旧在 OlapScanNode 中确定选择的 MVs 表。*
   
   *如果在整个查询前先选择 MVs,则有些可能包含一些可能可以被裁剪的列。*
   
   + step1:在生成完所有 ScanNode 后,开始对所有 ScanNode 进行 MVs 表的选择。
   + step2: 遍历所有的 ScanNode,并为其选择合适的 MVs 表。
   	+ Predicates 阶段:主要根据查询语句过滤不符合条件的 MVs,产生备选集合。
   		+ step2.1:筛选出 Projection 表中子集列中包含 AggInfo 中的 group by 列和 aggregate 列,作为备选。
   		+ step2.2:筛选出不包含聚合的  MVs 中列的子集中包含 Scan node 的所有列,作为备选。  
                   + step2.3: 如果是aggregate模型的表,且前面两次均为结果为空,则将key列包含全base 表的key列的rollup均加入备选。
   	+ Priorities 阶段:从备选集合中根据策略,选择出最优的  MV 作为结果。
   		+ step2.3:根据 ScanNode 的谓词,从备选  MVs 表中选择出对应前缀索引最多的  MVs 表。
      		+ step2.4:从第三步的结果中,根据 RowCount 选择出行数最小的  MVs。
      		+ step2.5: 从第四步的结果中,选出列数最小的  MV 表作为 ScanNode 的最终扫描表。
   
   **在不支持 SPJG 型  MVs 的情况下,聚合条件涉及多个表的多个列时,无法匹配到带预聚合的  MVs。但并不影响其匹配到其他非预聚合的  MVs**

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org