Skip to content

Commit

Permalink
Fixes an issue in selectivity calculation for IN operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ppanopticon committed May 24, 2024
1 parent c4d456c commit 7f7dd9e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class IndexScanPhysicalOperatorNode(override val groupId: Int,

/* Populate statistics. */
if (!this.statistics.containsKey(binding.physical) && entityProduces.contains(binding.physical)) {
this.statistics[binding.column] = entityTx.columnForName(binding.physical!!.name).newTx(this.index.context).statistics() as ValueStatistics<Value>
this.statistics[binding.physical] = entityTx.columnForName(binding.physical!!.name).newTx(this.index.context).statistics() as ValueStatistics<Value>
}
} else {
require(indexProduces.contains(binding.column)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ object NaiveSelectivityCalculator {
val right = predicate.operator.right
return when {
left is Binding.Literal && right is Binding.Literal -> if (left.getValue() == right.getValue()) Selectivity.ALL else Selectivity.NOTHING
left is Binding.Literal && right is Binding.Column -> statistics[right.physical]?.estimateSelectivity(predicate) ?: Selectivity.DEFAULT
left is Binding.Column && right is Binding.Literal -> statistics[left.physical]?.estimateSelectivity(predicate) ?: Selectivity.DEFAULT
left is Binding.Column && right is Binding.LiteralList -> statistics[left.physical]?.estimateSelectivity(predicate) ?: Selectivity.DEFAULT
left !is Binding.Column && right is Binding.Column -> statistics[right.physical]?.estimateSelectivity(predicate) ?: Selectivity.DEFAULT
left is Binding.Column && right !is Binding.Column -> statistics[left.physical]?.estimateSelectivity(predicate) ?: Selectivity.DEFAULT
else -> Selectivity.DEFAULT
}
}
Expand Down

0 comments on commit 7f7dd9e

Please sign in to comment.