Skip to content

Commit

Permalink
Break early of the row selection is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Jun 6, 2024
1 parent 8fd9983 commit e2dec61
Showing 1 changed file with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,37 @@ impl PagePruningPredicate {
&selection,
predicate.predicate_expr(),
);
overall_selection = update_selection(overall_selection, selection)

overall_selection = update_selection(overall_selection, selection);

// if the overall selection has ruled out all rows, no need to
// continue with the other predicates
let selects_any = overall_selection
.as_ref()
.map(|selection| selection.selects_any())
.unwrap_or(true);

if !selects_any {
break;
}
}

if let Some(overall_selection) = overall_selection {
let rows_skipped = rows_skipped(&overall_selection);
trace!("Overall selection from predicate skipped {rows_skipped}: {overall_selection:?}");
total_skip += rows_skipped;
access_plan.scan_selection(r, overall_selection)
if overall_selection.selects_any() {
let rows_skipped = rows_skipped(&overall_selection);
trace!("Overall selection from predicate skipped {rows_skipped}: {overall_selection:?}");
total_skip += rows_skipped;
access_plan.scan_selection(r, overall_selection)
} else {
// Selection skips all rows, so skip the entire row group
let rows_skipped = groups[r].num_rows() as usize;
access_plan.skip(r);
total_skip += rows_skipped;
trace!(
"Overall selection from predicate is empty, \
skipping all {rows_skipped} rows in row group {r}"
);
}
}
}

Expand Down

0 comments on commit e2dec61

Please sign in to comment.