This is an automated email from the ASF dual-hosted git repository.
huajianlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new b80d8393d49 [opt](partition pruner) add
cache_sorted_partition_interval_second (#58766)
b80d8393d49 is described below
commit b80d8393d4984b83810efd4fb1754c9eee5cc531
Author: 924060929 <[email protected]>
AuthorDate: Mon Dec 8 16:17:56 2025 +0800
[opt](partition pruner) add cache_sorted_partition_interval_second (#58766)
add cache_sorted_partition_interval_second to control the refresh
interval time for the cache of sorted partition
---
.../common/cache/NereidsSortedPartitionsCacheManager.java | 15 +++++++++++----
.../main/java/org/apache/doris/qe/SessionVariable.java | 12 ++++++++++++
2 files changed, 23 insertions(+), 4 deletions(-)
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 37b8f75854a..aee8122d7f4 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
@@ -31,6 +31,7 @@ import
org.apache.doris.nereids.rules.expression.rules.SortedPartitionRanges.Par
import
org.apache.doris.nereids.rules.expression.rules.SortedPartitionRanges.PartitionItemAndRange;
import org.apache.doris.nereids.trees.plans.algebra.CatalogRelation;
import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.SessionVariable;
import org.apache.doris.rpc.RpcException;
import com.github.benmanes.caffeine.cache.Cache;
@@ -80,6 +81,7 @@ public class NereidsSortedPartitionsCacheManager {
return Optional.empty();
}
+ SessionVariable sessionVariable = connectContext.getSessionVariable();
DatabaseIf<?> database = table.getDatabase();
if (database == null) {
return Optional.empty();
@@ -94,13 +96,13 @@ public class NereidsSortedPartitionsCacheManager {
try {
if (partitionCacheContext == null) {
- return Optional.ofNullable(loadCache(key, table, scan));
+ return Optional.ofNullable(loadCache(key, table, scan,
sessionVariable));
}
if (table.getId() != partitionCacheContext.tableId
|| !Objects.equals(table.getPartitionMetaVersion(scan),
partitionCacheContext.partitionMetaVersion)) {
partitionCaches.invalidate(key);
- return Optional.ofNullable(loadCache(key, table, scan));
+ return Optional.ofNullable(loadCache(key, table, scan,
sessionVariable));
}
} catch (Throwable t) {
LOG.warn("Failed to load cache for table {}, key {}.",
table.getName(), key, t);
@@ -116,13 +118,18 @@ public class NereidsSortedPartitionsCacheManager {
}
private SortedPartitionRanges<?> loadCache(
- TableIdentifier key, SupportBinarySearchFilteringPartitions table,
CatalogRelation scan)
+ TableIdentifier key, SupportBinarySearchFilteringPartitions table,
CatalogRelation scan,
+ SessionVariable sessionVariable)
throws RpcException {
long now = System.currentTimeMillis();
long partitionMetaLoadTime =
table.getPartitionMetaLoadTimeMillis(scan);
+ long cacheSortedPartitionIntervalSecond =
sessionVariable.cacheSortedPartitionIntervalSecond;
+
// if insert too frequently, we will skip sort partitions
- if (now <= partitionMetaLoadTime || (now - partitionMetaLoadTime) <=
(10 * 1000)) {
+ if (cacheSortedPartitionIntervalSecond >= 0
+ && (now <= partitionMetaLoadTime
+ || (now - partitionMetaLoadTime) <=
(cacheSortedPartitionIntervalSecond * 1000))) {
return null;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index 66f1186180b..5e51b0ee374 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -182,6 +182,7 @@ public class SessionVariable implements Serializable,
Writable {
public static final String ENABLE_REWRITE_ELEMENT_AT_TO_SLOT =
"enable_rewrite_element_at_to_slot";
public static final String ENABLE_ODBC_TRANSCATION =
"enable_odbc_transcation";
public static final String ENABLE_BINARY_SEARCH_FILTERING_PARTITIONS =
"enable_binary_search_filtering_partitions";
+ public static final String CACHE_SORTED_PARTITION_INTERVAL_SECOND =
"cache_sorted_partition_interval_second";
public static final String SKIP_PRUNE_PREDICATE = "skip_prune_predicate";
public static final String ENABLE_SQL_CACHE = "enable_sql_cache";
public static final String ENABLE_HIVE_SQL_CACHE = "enable_hive_sql_cache";
@@ -1306,6 +1307,17 @@ public class SessionVariable implements Serializable,
Writable {
)
public boolean enableBinarySearchFilteringPartitions = true;
+ @VariableMgr.VarAttr(
+ name = CACHE_SORTED_PARTITION_INTERVAL_SECOND,
+ fuzzy = false,
+ description = {
+ "表数据更新后,多少秒之内不能使用二分查找分区裁剪",
+ "After updating table data, within how many seconds can "
+ + "binary search partitioning and pruning not be
used."
+ }
+ )
+ public int cacheSortedPartitionIntervalSecond = 10;
+
@VariableMgr.VarAttr(name = SKIP_PRUNE_PREDICATE, fuzzy = true,
description = {
"是否跳过“在分区裁剪后删除恒真谓词”的优化。默认为 OFF(即执行此优化)。",
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]