amansinha100 commented on a change in pull request #1699: DRILL-7108: Improve
selectivity estimates for (NOT)LIKE, NOT_EQUALS, IS NOT NULL predicates
URL: https://github.com/apache/drill/pull/1699#discussion_r267156795
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdSelectivity.java
##########
@@ -173,6 +177,58 @@ private double getScanSelectivityInternal(DrillTable
table, RexNode predicate, L
return (sel > 1.0) ? 1.0 : sel;
}
+ private double computeEqualsSelectivity(DrillTable table, RexNode orPred,
List<String> fieldNames) {
+ String col = getColumn(orPred, fieldNames);
+ if (col != null) {
+ if (table.getStatsTable() != null
+ && table.getStatsTable().getNdv(col) != null) {
+ return 1.00 / table.getStatsTable().getNdv(col);
+ }
+ }
+ return guessSelectivity(orPred);
+ }
+
+ private double computeIsNullSelectivity(DrillTable table, RexNode orPred,
List<String> fieldNames) {
+ String col = getColumn(orPred, fieldNames);
+ if (col != null) {
+ if (table.getStatsTable() != null
+ && table.getStatsTable().getNNRowCount(col) != null) {
+ // Cap selectivity between {1/Total_Rows, Calcite Guess}
+ return Math.min(Math.max(1.0/table.getStatsTable().getRowCount(),
Review comment:
I missed the 1/getRowCount()...why not just min( (1 -
NNRowCount/totalRowCount), guessSelectivity) ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services