eldenmoon commented on code in PR #18654:
URL: https://github.com/apache/doris/pull/18654#discussion_r1191856283


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java:
##########
@@ -195,6 +197,45 @@ public PhysicalPlanTranslator(PlanTranslatorContext 
context, StatsErrorEstimator
         this.statsErrorEstimator = statsErrorEstimator;
     }
 
+    // We use two phase read to optimize sql like: select * from tbl [where 
xxx = ???] [order by column1] [limit n]
+    // in the first phase, we add an extra column `RowId` to Block, and sort 
blocks in TopN nodes
+    // in the second phase, we have n rows, we do a fetch rpc to get all 
rowids data for the n rows
+    // and reconconstruct the final block
+    private void setResultSinkFetchOptionIfNeed() {
+        boolean needFetch = false;
+        // Only single olap table should be fetched
+        OlapTable fetchOlapTable = null;
+        for (PlanFragment fragment : context.getPlanFragments()) {

Review Comment:
   sortNode.getUseTwoPhaseReadOpt() flag makes sure the query is simple enough



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