airborne12 commented on code in PR #67180:
URL: https://github.com/apache/doris/pull/67180#discussion_r4092607905


##########
be/src/storage/segment/segment_iterator.cpp:
##########
@@ -820,6 +815,38 @@ Status 
SegmentIterator::_get_row_ranges_by_column_conditions() {
         return Status::OK();
     }
 
+    // Apply stable scan restrictions before evaluating inverted-index 
expressions so
+    // selective restrictions can also serve as phrase-query candidates. The 
candidate
+    // pointer keeps referring to _row_bitmap as later predicates shrink it.
+    auto delete_bitmap_it = _opts.delete_bitmap.find(segment_id());
+    if (delete_bitmap_it != _opts.delete_bitmap.end() && 
delete_bitmap_it->second != nullptr) {
+        size_t pre_size = _row_bitmap.cardinality();
+        _row_bitmap -= *delete_bitmap_it->second;
+        _opts.stats->rows_del_by_bitmap += (pre_size - 
_row_bitmap.cardinality());
+        VLOG_DEBUG << "read on segment: " << segment_id()
+                   << ", delete bitmap cardinality: " << 
delete_bitmap_it->second->cardinality()
+                   << ", " << _opts.stats->rows_del_by_bitmap << " rows 
deleted by bitmap";
+    }
+
+    if (!_opts.row_ranges.is_empty()) {
+        _row_bitmap &= RowRanges::ranges_to_roaring(_opts.row_ranges);
+    }
+
+    if (!_row_bitmap.isEmpty() &&

Review Comment:
   Confirmed and fixed in ca2a944fab8. A focused test with the ratio set to 0 
and an empty inverted-index result observed one zone-map read before the fix 
and zero after it. Early scan restriction now applies only when candidate 
pushdown is enabled and a standalone phrase or phrase-prefix expression can use 
candidates; ratio-0 and non-phrase scans evaluate the index first. The ASAN BE 
build and 20 targeted unit tests passed.
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to