yx-keith opened a new pull request, #71422:
URL: https://github.com/apache/doris/pull/71422

   ### Background
   
   An incremental materialized view can process row-level changes or rebuild 
affected partitions. Doris AUTO refresh tries the applicable modes in a fixed 
order. The FE already tracks changelog row counts and partition index 
statistics.
   
   ### What problem does this PR solve?
   
   Issue Number: #65418
   Related PR: #69850 (Stream baseline estimates), #69856 (committed refresh 
method reporting)
   PR Type: Feature
   
   Problem Summary: A dense change window can cost more to process row by row 
than to rebuild the same partitions. Add a read-only cost explanation and an 
opt-in AUTO policy for eligible single-table IVM views.
   
   ### Details
   
   - **Change map:** 432 production lines added, 7 removed, and 571 test lines 
added. Production work covers eligibility, byte estimates, task routing, and 
the EXPLAIN entry point. Tests cover both recommendations, selection gates, and 
the next incremental refresh after a partition rebuild.
   - **Scope:** Shared-nothing IVM views with one native OLAP scan, an 
established refresh baseline, and an exact one-to-one partition mapping. Both 
candidates must cover the same pending changes. Unknown statistics or unstable 
scope retain the existing AUTO policy.
   - **Design:** Compare estimated read bytes, write bytes, and one sink 
exchange for each candidate. Reuse the assessed partition plan and the existing 
COMPLETE recovery path. Fixed ordering remains the default. Equal costs keep 
the incremental candidate. The proposed policy is presented here for design 
discussion under #65418.
   - **Usage:** For an eligible existing view named `mv`, inspect the 
recommendation, turn on selection for the view, and run an AUTO refresh.
   
     ```sql
     EXPLAIN REFRESH MATERIALIZED VIEW mv AUTO;
     ALTER MATERIALIZED VIEW mv SET ("ivm_cost_based_auto_refresh" = "true");
     REFRESH MATERIALIZED VIEW mv AUTO;
     ```
   
   - **Default behavior:** `ivm_cost_based_auto_refresh` defaults to `false`. 
Explicit refresh modes and ineligible AUTO requests retain their existing 
behavior.
   - **Compatibility:** The option uses the existing persisted MV property map. 
Existing views without the property retain their refresh policy. The feature 
uses existing FE-to-BE plans and existing stream-offset and refresh transaction 
protocols.
   - **Deployment modes:** Shared-nothing mode supports the opt-in policy. In 
cloud mode, EXPLAIN reports the comparison as unavailable and AUTO uses its 
existing policy.
   
   ### Testing
   
   Diff whitespace and Java line-length checks passed on `fe763b570cb` after 
rebase onto `2b3344209fa`. The branch adds FE test coverage for the cost model, 
task routing, and EXPLAIN, plus a SQL regression comparing the next incremental 
refresh against a base-table query. FE compilation, unit tests, and SQL 
regressions are pending. Performance has not been measured.
   
   ### Release note
   
   Eligible IVM views can opt into cost-based AUTO refresh. `EXPLAIN REFRESH 
MATERIALIZED VIEW ... AUTO` reports the recommendation and byte estimates or 
explains why the comparison is unavailable.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: Yes (document EXPLAIN AUTO and the opt-in MV 
property in the IVM guide)
   - Pre-submission status: Partially verified: compilation, UT, SQL 
regressions, and performance measurements are pending.
   
   ### AI Disclosure
   
   - Tool: Codex.
   - Generated: Code, tests, and the initial description draft.
   - Human review: Not stated.
   


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