yujun777 opened a new pull request, #71071: URL: https://github.com/apache/doris/pull/71071
### Background During incremental materialized view refresh, a change on the null-producing side of an equi-join can add or remove a NULL-extended row. When the matching key is non-unique, the refresh groups the changed keys and uses an anti join against the pre-refresh or post-refresh snapshot to detect that transition. ### What problem does this PR solve? Issue Number: None Related PR: #70922 (the INNER and CROSS JOIN optimization) PR Type: Performance Problem Summary: A NULL repair anti join can build its hash table over a large snapshot even when the refresh affects a few keys. If invalid statistics automatically disable join reordering, the optimizer can still consider building this particular anti join on the affected keys. ### Details - **Why it was slow:** The existing LEFT ANTI orientation uses the snapshot as its hash build input. In a directional A/B test, the hash build consumed 8 million rows to evaluate 32 affected keys. - **Optimization:** Identify the anti join generated for non-unique equality keys. After a statistics check automatically disables reordering, offer one RIGHT ANTI alternative in the same Memo group when the rewritten join still supports hashing and the snapshot exceeds the configured broadcast row limit. The optimizer compares the existing orientation and the new one. - **Results:** With an 8-million-row snapshot and 32 keys, test queries on the same single-BE ASAN runtime on a Xeon Platinum 8457C host returned the same 16 unmatched keys. Both plans used bucket shuffle. Across five interleaved warm runs per direction, median client wall time was 1.49 s for LEFT ANTI and 0.28 s for RIGHT ANTI. The hash build operator reported a peak of 109.78 MB and 30.52 MB, respectively. With a 16-row snapshot, LEFT ANTI chose broadcast and ran in 0.07 s median, compared with 0.13 s for RIGHT ANTI. These measurements cover the isolated anti join. - **Applicability and cost:** Local exploration adds at most one orientation per eligible join. Snapshot scans can still be large, and the cost model accounts for shuffle. Small snapshots keep their automatic broadcast option. Explicit reordering and distribution decisions take precedence. ### Testing - FE package and Checkstyle passed. - 75 FE unit tests passed across JoinCommuteTest, IvmJoinDeltaHandlerTest, StatsCalculatorTest, and StreamScanRowCountTest. - The new IVM regression passed end to end. It checks LEFT ANTI broadcast for a small snapshot, RIGHT ANTI for a large snapshot, and the rows after insertion and deletion of matching keys. - A refresh-plan check with explicit join reordering disabled kept both large-snapshot anti joins in their original orientation. ### Release note Incremental refresh can reduce the hash build footprint of eligible NULL repair anti joins against large snapshots. ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Partially verified: the IVM directory run is in progress. The directional performance comparison used an ASAN build. -- 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]
