Skip to content

Commit

Permalink
More comments, justifying calls to index_row_est
Browse files Browse the repository at this point in the history
  • Loading branch information
gefjon committed Nov 12, 2024
1 parent ec05682 commit ac69777
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/core/src/estimation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ fn row_est(tx: &Tx, src: &SourceExpr, ops: &[Query]) -> u64 {
// We assume a uniform distribution of keys,
// which implies a selectivity = 1 / NDV,
// where NDV stands for Number of Distinct Values.
// We assume that the table exists and has an index on the columns,
// so `index_row_est` will only return 0 if the table is empty.
Query::IndexScan(scan) if scan.is_point() => {
index_row_est(tx, scan.table.table_id, &scan.columns)
}
Expand All @@ -41,6 +43,8 @@ fn row_est(tx: &Tx, src: &SourceExpr, ops: &[Query]) -> u64 {
Query::IndexJoin(join) => {
row_est(tx, &join.probe_side.source, &join.probe_side.query)
.saturating_mul(
// We assume that the table exists and has an index on the columns,
// so `index_row_est` will only return 0 if the table is empty.
index_row_est(tx, src.table_id().unwrap(), &join.index_col.into())
)
}
Expand Down

0 comments on commit ac69777

Please sign in to comment.