Skip to content

Commit

Permalink
[Enhancement](inverted index) apply inverted index when has any (apac…
Browse files Browse the repository at this point in the history
…he#41547)

## Proposed changes

This PR optimizes the inverted index logic by skipping the execution of
inverted index conditions when none are present. This change improves
performance by avoiding unnecessary inverted index condition flow.
  • Loading branch information
airborne12 authored and amorynan committed Oct 12, 2024
1 parent 7f41439 commit 2e96b02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion be/src/olap/rowset/segment_v2/segment_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ Status SegmentIterator::_get_row_ranges_by_column_conditions() {
RETURN_IF_ERROR(_apply_bitmap_index());
{
if (_opts.runtime_state &&
_opts.runtime_state->query_options().enable_inverted_index_query) {
_opts.runtime_state->query_options().enable_inverted_index_query &&
has_inverted_index_in_iterators()) {
SCOPED_RAW_TIMER(&_opts.stats->inverted_index_filter_timer);
size_t input_rows = _row_bitmap.cardinality();
RETURN_IF_ERROR(_apply_inverted_index());
Expand Down
5 changes: 5 additions & 0 deletions be/src/olap/rowset/segment_v2/segment_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ class SegmentIterator : public RowwiseIterator {
return _inverted_index_iterators;
}

bool has_inverted_index_in_iterators() const {
return std::any_of(_inverted_index_iterators.begin(), _inverted_index_iterators.end(),
[](const auto& iterator) { return iterator != nullptr; });
}

private:
Status _next_batch_internal(vectorized::Block* block);

Expand Down

0 comments on commit 2e96b02

Please sign in to comment.