seawinde commented on code in PR #63081:
URL: https://github.com/apache/doris/pull/63081#discussion_r3232396627


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/PartitionCompensator.java:
##########
@@ -198,7 +198,8 @@ private static Pair<Pair<BaseTableInfo, Set<String>>, 
Pair<BaseColInfo, Set<Stri
                 // Base table partition maybe deleted, need not union
                 continue;
             }
-            baseTableNeedUnionPartitionNameSet.addAll(baseTablePartitions);
+            Sets.intersection(baseTablePartitions, 
queryUsedBaseTablePartitionNameSet)

Review Comment:
    The fix looks reasonable to me. This path should only compensate base-table 
partitions that are actually used by the query; otherwise invalid MV partitions 
outside the query range can create unnecessary UNION branches and make the MV 
candidate more
     expensive.
   
     Could you add a regression test  or ut test for this case? For example, 
the query only uses `{p20260401, p20260402, p20260403}`, but the rewritten MV 
scan selects a wider range and some query-unused MV partitions are removed as 
invalid. The expected result is that
     `baseTableNeedUnionPartitionNameSet` only contains partitions intersecting 
with the query-used base partitions, and does not include those query-unused 
partitions.



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