xinyiZzz commented on a change in pull request #6154:
URL: https://github.com/apache/incubator-doris/pull/6154#discussion_r666702514



##########
File path: docs/zh-CN/administrator-guide/runtime-filter.md
##########
@@ -0,0 +1,223 @@
+---
+{
+    "title": "Runtime Filter",
+    "language": "zh-CN"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Runtime Filter
+Runtime Filter 是在 Doris 0.15 版本中正式加入的新功能。旨在为某些 Join 
查询在运行时动态生成过滤条件,来减少扫描的数据量,避免不必要的I/O和网络传输,从而加速查询。
+
+它的设计、实现和效果可以参阅 [ISSUE 
6116](https://github.com/apache/incubator-doris/issues/6116)。
+
+## 名词解释
+* FE:Frontend,Doris 的前端节点。负责元数据管理和请求接入。
+* BE:Backend,Doris 的后端节点。负责查询执行和数据存储。
+* 左表:Join查询时,左边的表。进行Probe操作。可被Join Reorder调整顺序。
+* 右表:Join查询时,右边的表。进行Build操作。可被Join Reorder调整顺序。
+* Fragment:FE会将具体的SQL语句的执行转化为对应的Fragment并下发到BE进行执行。BE上执行对应Fragment,并将结果汇聚返回给FE。
+* Join on clause: `A join B on A.a=B.b`中的`A.a=B.b`,在查询规划时基于此生成join 
conjuncts,包含join Build和Probe使用的expr,其中Build expr在Runtime Filter中称为src 
expr,Probe expr在Runtime Filter中称为target expr。
+
+## 原理
+Runtime Filter在查询规划时生成,在HashJoinNode中构建,在ScanNode中应用。
+
+举个例子,当前存在T1表与T2表的Join查询,它的Join方式为HashJoin,T1是一张事实表,数据行数为100000,T2是一张维度表,数据行数为100,Doris
 join的实际情况是:
+```
+|          >      HashJoinNode     <
+|         |                         |
+|         | 100000                  | 2000
+|         |                         |
+|   OlapScanNode              OlapScanNode
+|         ^                         ^   
+|         | 100000                  | 2000
+|        T1                        T2
+|
+```
+显而易见对T2扫描数据要远远快于T1,如果我们主动等待一段时间再扫描T1,等T2将扫描的数据记录交给HashJoinNode后,HashJoinNode根据T2的数据计算出一个过滤条件,比如T2数据的最大和最小值,或者构建一个Bloom
 Filter,接着将这个过滤条件发给等待扫描T1的ScanNode,后者应用这个过滤条件,将过滤后的数据交给HashJoinNode,从而减少probe 
hash table的次数和网络开销,这个过滤条件就是Runtime Filter,效果如下:
+```
+|          >      HashJoinNode     <
+|         |                         |
+|         | 6000                    | 2000
+|         |                         |
+|   OlapScanNode              OlapScanNode
+|         ^                         ^   
+|         | 100000                  | 2000
+|        T1                        T2
+|
+```
+如果能将过滤条件(Runtime Filter)下推到存储引擎,则某些情况下可以利用索引来直接减少扫描的数据量,从而大大减少扫描耗时,效果如下:
+```
+|          >      HashJoinNode     <
+|         |                         |
+|         | 6000                    | 2000
+|         |                         |
+|   OlapScanNode              OlapScanNode
+|         ^                         ^   
+|         | 6000                    | 2000
+|        T1                        T2
+|
+```
+可见,和谓词下推、分区裁剪不同,Runtime Filter是在运行时动态生成的过滤条件,即在查询运行时解析join on 
clause确定过滤表达式,并将表达式广播给正在读取左表的ScanNode,从而减少扫描的数据量,进而减少probe hash 
table的次数,避免不必要的I/O和网络传输。
+
+Runtime Filter主要用于优化针对大表的join,如果左表的数据量太小,或者右表的数据量太大,则Runtime Filter可能不会取得预期效果。
+
+## 使用方式
+
+### 设置Session变量

Review comment:
       Modified, thks




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to