This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new a0726e8f275 branch-4.0: [opt](partition pruner) add
cache_sorted_partition_interval_second #58766 (#58809)
a0726e8f275 is described below
commit a0726e8f275bac85f98d0d16ee50a11c435fcc8b
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Dec 11 19:18:21 2025 +0800
branch-4.0: [opt](partition pruner) add
cache_sorted_partition_interval_second #58766 (#58809)
Cherry-picked from #58766
Co-authored-by: 924060929 <[email protected]>
---
.../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 9a7d86b53ec..c74f14a8fde 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
@@ -180,6 +180,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";
@@ -1290,6 +1291,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]