Skip to content

Commit

Permalink
range-selectivity-threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Aug 29, 2024
1 parent 1fb04de commit ac96399
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
*/
public class FilterEstimation extends ExpressionVisitor<Statistics, EstimationContext> {
public static final double DEFAULT_INEQUALITY_COEFFICIENT = 0.5;
public static final double RANGE_SELECTIVITY_THRESHOULD = 0.01;
public static final double DEFAULT_IN_COEFFICIENT = 1.0 / 3.0;

public static final double DEFAULT_HAVING_COEFFICIENT = 0.01;
Expand Down Expand Up @@ -597,6 +598,8 @@ private Statistics estimateBinaryComparisonFilter(Expression leftExpr, DataType
double sel = leftRange.overlapPercentWith(rightRange);
if (!(dataType instanceof RangeScalable) && (sel != 0.0 && sel != 1.0)) {
sel = DEFAULT_INEQUALITY_COEFFICIENT;
} else if (sel < RANGE_SELECTIVITY_THRESHOULD) {
sel = RANGE_SELECTIVITY_THRESHOULD;
}
sel = getNotNullSelectivity(leftStats, sel);
updatedStatistics = context.statistics.withSel(sel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,9 @@ public void testLargeRange() {
.setCount(row)
.setNdv(10000)
.setMinExpr(new IntLiteral(0))
.setMinValue(0)
.setMaxExpr(new IntLiteral(tenB))
.setMaxValue(tenB)
.build();
Statistics stats = new StatisticsBuilder()
.setRowCount(row)
Expand All @@ -1310,6 +1312,6 @@ public void testLargeRange() {
Expression pred = new LessThan(a, new IntegerLiteral(50000));
FilterEstimation estimation = new FilterEstimation();
Statistics out = estimation.estimate(pred, stats);
System.out.println(out);
Assertions.assertEquals(out.getRowCount(), row * FilterEstimation.RANGE_SELECTIVITY_THRESHOULD);
}
}

0 comments on commit ac96399

Please sign in to comment.