Skip to content

Commit

Permalink
set session var for range filter lower bound
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Aug 30, 2024
1 parent 759a95a commit 5d22f14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.apache.doris.nereids.types.DataType;
import org.apache.doris.nereids.types.DateTimeType;
import org.apache.doris.nereids.types.coercion.RangeScalable;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.statistics.ColumnStatistic;
import org.apache.doris.statistics.ColumnStatisticBuilder;
import org.apache.doris.statistics.StatisticRange;
Expand Down Expand Up @@ -598,10 +599,14 @@ private Statistics estimateBinaryComparisonFilter(Expression leftExpr, DataType
.setNdv(intersectRange.getDistinctValues())
.setNumNulls(0);
double sel = leftRange.overlapPercentWith(rightRange);
double lowerBound = RANGE_SELECTIVITY_THRESHOLD;
if (ConnectContext.get() != null) {
lowerBound = ConnectContext.get().getSessionVariable().rangeFilterLowerBound;
}
if (!(dataType instanceof RangeScalable) && (sel != 0.0 && sel != 1.0)) {
sel = DEFAULT_INEQUALITY_COEFFICIENT;
} else if (sel < RANGE_SELECTIVITY_THRESHOLD) {
sel = RANGE_SELECTIVITY_THRESHOLD;
} else if (sel < lowerBound) {
sel = lowerBound;
}
sel = getNotNullSelectivity(leftStats, sel);
updatedStatistics = context.statistics.withSel(sel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,11 @@ public void setEnableLeftZigZag(boolean enableLeftZigZag) {

public String ignoreRuntimeFilterIds = "";

@VariableMgr.VarAttr(name = "range_filter_lower_bound",
description = {"", ""})

public Double rangeFilterLowerBound = 0.01;

@VariableMgr.VarAttr(name = STATS_INSERT_MERGE_ITEM_COUNT, flag = VariableMgr.GLOBAL, description = {
"控制统计信息相关INSERT攒批数量", "Controls the batch size for stats INSERT merging."
}
Expand Down

0 comments on commit 5d22f14

Please sign in to comment.