Jian Zhang has posted comments on this change. ( http://gerrit.cloudera.org:8080/18862 )
Change subject: IMPALA-11485: Pushdown LIMIT through UNION and LEFT/RIGHT OUTER JOIN ...................................................................... Patch Set 4: (2 comments) http://gerrit.cloudera.org:8080/#/c/18862/4/fe/src/main/java/org/apache/impala/planner/SingleNodePlanner.java File fe/src/main/java/org/apache/impala/planner/SingleNodePlanner.java: http://gerrit.cloudera.org:8080/#/c/18862/4/fe/src/main/java/org/apache/impala/planner/SingleNodePlanner.java@396 PS4, Line 396: private static PlanNode findNodeCanLimitPushdown(PlanNode root) { This function can only find the first `union all` or `join` node in the plan tree and push the `limit` down. However, I think we should find all the descendant `union all` or `join` nodes and push the `limit` down. For example: limit 10 -> left outer join -> left outer join -> table scan t1 -> table scan t2 -> table scan t3 can be optimized to the following plan after applying limit pushdown: limit 10 -> left outer join -> limit 10 -> left outer join -> limit 10 -> table scan t1 -> table scan t2 -> table scan t3 http://gerrit.cloudera.org:8080/#/c/18862/4/fe/src/main/java/org/apache/impala/planner/SingleNodePlanner.java@397 PS4, Line 397: if (root == null || root instanceof UnionNode || root instanceof HashJoinNode) { Should we check whether it's `JoinNode` instead of `HashJoinNode` since this happens in the single-node planning phase, in which the physical plan is not determined? I noticed there is another join implementation called `NestedLoopJoin`, it should also be covered by this optimization -- To view, visit http://gerrit.cloudera.org:8080/18862 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia5d040c0a98e60639d7ce4b25ecf07a859c8a32c Gerrit-Change-Number: 18862 Gerrit-PatchSet: 4 Gerrit-Owner: Baike Xia <xiaba...@163.com> Gerrit-Reviewer: Aman Sinha <amsi...@cloudera.com> Gerrit-Reviewer: Csaba Ringhofer <csringho...@cloudera.com> Gerrit-Reviewer: Impala Public Jenkins <impala-public-jenk...@cloudera.com> Gerrit-Reviewer: Jian Zhang <zjsar...@gmail.com> Gerrit-Reviewer: Quanlong Huang <huangquanl...@gmail.com> Gerrit-Comment-Date: Tue, 13 Sep 2022 02:33:31 +0000 Gerrit-HasComments: Yes