Jackie-Jiang commented on code in PR #16277:
URL: https://github.com/apache/pinot/pull/16277#discussion_r2190886872


##########
pinot-core/src/main/java/org/apache/pinot/core/operator/query/GroupByOperator.java:
##########
@@ -138,8 +140,16 @@ protected GroupByResultsBlock getNextBlock() {
     // TODO: Currently the groups are not trimmed if there is no ordering 
specified. Consider ordering on group-by
     //       columns if no ordering is specified.
     int minGroupTrimSize = _queryContext.getMinSegmentGroupTrimSize();
-    if (_queryContext.getOrderByExpressions() != null && minGroupTrimSize > 0) 
{
-      int trimSize = GroupByUtils.getTableCapacity(_queryContext.getLimit(), 
minGroupTrimSize);
+    int trimSize = -1;
+    List<OrderByExpressionContext> orderByExpressions = 
_queryContext.getOrderByExpressions();
+    if (QueryContext.isSameOrderAndGroupByColumns(_queryContext) && 
_queryContext.getHavingFilter() == null) {

Review Comment:
   This should be the same as `!QueryContext.isUnsafeTrim()`



##########
pinot-core/src/main/java/org/apache/pinot/core/operator/query/GroupByOperator.java:
##########
@@ -138,8 +140,16 @@ protected GroupByResultsBlock getNextBlock() {
     // TODO: Currently the groups are not trimmed if there is no ordering 
specified. Consider ordering on group-by
     //       columns if no ordering is specified.
     int minGroupTrimSize = _queryContext.getMinSegmentGroupTrimSize();
-    if (_queryContext.getOrderByExpressions() != null && minGroupTrimSize > 0) 
{
-      int trimSize = GroupByUtils.getTableCapacity(_queryContext.getLimit(), 
minGroupTrimSize);
+    int trimSize = -1;
+    List<OrderByExpressionContext> orderByExpressions = 
_queryContext.getOrderByExpressions();
+    if (QueryContext.isSameOrderAndGroupByColumns(_queryContext) && 
_queryContext.getHavingFilter() == null) {

Review Comment:
   Not introduced in this PR, but given this `isUnsafeTrim()` is called 
multiple times, and it is not a cheap operation, we should pre-compute it and 
cache it in `QueryContext`. cc @bziobrowski 



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