Jackie-Jiang commented on a change in pull request #8263:
URL: https://github.com/apache/pinot/pull/8263#discussion_r816199611



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/plan/SelectionPlanNode.java
##########
@@ -56,14 +56,16 @@ public SelectionPlanNode(IndexSegment indexSegment, 
QueryContext queryContext) {
       if (orderByExpressions == null) {
         // Selection only
         TransformOperator transformOperator = new 
TransformPlanNode(_indexSegment, _queryContext, expressions,
-            Math.min(limit + _queryContext.getOffset(), 
DocIdSetPlanNode.MAX_DOC_PER_CALL)).run();
+            Math.min(limit, DocIdSetPlanNode.MAX_DOC_PER_CALL)).run();
         return new SelectionOnlyOperator(_indexSegment, _queryContext, 
expressions, transformOperator);
       } else {
-        if (isAllOrderByColumnsSorted(orderByExpressions)) { // no sorting 
needed
-          TransformOperator transformOperator =
-              new TransformPlanNode(_indexSegment, _queryContext, expressions, 
DocIdSetPlanNode.MAX_DOC_PER_CALL).run();
+        // Selection order-by
+        if (isAllOrderByColumnsSorted(orderByExpressions)) {
+          // All order-by columns are sorted, no need to sort the records
+          TransformOperator transformOperator = new 
TransformPlanNode(_indexSegment, _queryContext, expressions,
+              Math.min(limit + _queryContext.getOffset(), 
DocIdSetPlanNode.MAX_DOC_PER_CALL)).run();

Review comment:
       With order-by, should scan `limit + offset` records




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