HappenLee opened a new pull request, #71428: URL: https://github.com/apache/doris/pull/71428
### Background A Doris rowset can store the minimum and maximum encoded keys for each segment. Today the rowset reader creates a lazy iterator for every segment assigned to a scan. Initializing an iterator can require a remote footer read on a cold cache. ### What problem does this PR solve? Issue Number: None Related PR: None PR Type: Performance Problem Summary: For a table sorted by `(tenant_id, order_id)`, a query for `tenant_id = 123` can rule out a segment whose largest tenant ID is 100 using metadata already in memory. This change makes that decision before creating the segment iterator. The surviving segments keep their original IDs and scan splits. ### Details - **Why it was slow:** The reader handed every assigned segment to the iterator path even when the rowset's key bounds could prove that it contained no matching rows. - **Optimization:** Encode scan keys as half-open intervals, merge overlapping intervals once per rowset reader, and use binary search to check each segment for overlap. A usable aggregate bound can exclude an entire rowset. The scan profile counts early exclusions in `NumSegmentFilteredByKeyBounds`. - **Results:** Cold object-store request counts, bytes read and end-to-end latency have not been measured. - **Applicability and cost:** Equality, IN and range predicates on the leftmost sort-key columns can benefit. Preparing the intervals costs memory and sorting time even when every segment overlaps. Missing or ambiguous bounds retain the segment. Non-final variable-length strings can widen the interval because their encoding has no terminator. Cluster-key and non-lexically sorted rowsets keep their existing scan path. ### Testing Added `BetaRowsetTest.PrefixKeyBoundsPruneBeforeOpeningSegments` for partial, full and empty matches, disjoint ranges, metadata fallback, and physical segment IDs with a delete bitmap and a split scan. The local BE test build stopped during dependency setup, before compilation or test execution. ### Release note Queries with sort-key prefix predicates can skip opening segments when rowset metadata rules out a match. ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Partially verified: compilation, test execution and cold object-store performance are outstanding. ### AI Disclosure - Tool: OpenAI Codex (GPT-6) - Generated: Implementation, unit test and PR description. - Human review: Review coverage has not been reported. -- 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]
