diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/cache/NereidsSortedPartitionsCacheManager.java b/fe/fe-core/src/main/java/org/apache/doris/common/cache/NereidsSortedPartitionsCacheManager.java index d13b91e15fb6fc..499c3b46709578 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/cache/NereidsSortedPartitionsCacheManager.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/cache/NereidsSortedPartitionsCacheManager.java @@ -45,7 +45,13 @@ import java.util.Map.Entry; import java.util.Optional; -/** NereidsSortedPartitionsCacheManager */ +/** + * This cache is used to sort the table partitions by range, so we can do binary search to skip + * filter the huge numbers of partitions, for example, the table partition column is `dt date` + * and one date for one partition, range from '2017-01-01' to '2025-01-01', for partition predicate + * `where dt = '2024-12-24'`, we can fast jump to '2024-12-24' within few partition range comparison, + * and the QPS can be improved + */ public class NereidsSortedPartitionsCacheManager { private volatile Cache partitionCaches; @@ -74,7 +80,7 @@ public Optional> get(OlapTable table) { if (table.getId() != partitionCacheContext.tableId || table.getVisibleVersion() != partitionCacheContext.tableVersion) { partitionCaches.invalidate(key); - return Optional.empty(); + return Optional.of(loadCache(key, table)); } return Optional.of(partitionCacheContext.sortedPartitionRanges); }