You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/02/19 01:17:42 UTC

[GitHub] [pinot] jt-kloudfuse commented on a change in pull request #8228: Early terminate orderby when columns already sorted

jt-kloudfuse commented on a change in pull request #8228:
URL: https://github.com/apache/pinot/pull/8228#discussion_r810425988



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/query/SelectionOrderByOperator.java
##########
@@ -117,6 +119,30 @@ public String toExplainString() {
     return stringBuilder.append(')').toString();
   }
 
+  private void pruneOrderByColumns() {
+    // Order by col1, col2 limit k will take all the n matching rows
+    // and add it to a priority queue of size k.
+    // This is nlogk operation which can be quite expensive for a large n.
+    // This function, prunes out any order by clause that matches columns sorting order.
+    // In the above example, if the docs are already sorted by col1, col2 then there is no need for any
+    // sorting at all (only limit is needed). When only col1 is sorted, then we need to use only col2 for ordering.

Review comment:
       Actually, the comment is wrong. We apply the optimization (early termination) only if all columns are sorted. Lemme fix it up




-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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