raghav-reglobe opened a new pull request, #66804:
URL: https://github.com/apache/doris/pull/66804

   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #xxx
   
   Problem Summary:
   
   `NereidsCoordinator.setForInsert()` unconditionally sets 
`disableFileCache(true)`, so the source scan of every `INSERT ... SELECT` / 
CTAS is classified into the **disposable** file cache queue (the comment 
explains the intent: keep one-shot load scans from polluting the normal LRU).
   
   That one-shot assumption doesn't hold for a common warehouse shape: 
recurring ETL. Hourly dbt-style builds re-read the same source tables (in our 
case Iceberg external tables) every cycle — but because the disposable queue is 
capped at 5% of the cache and hits never promote, those scans re-fetch from 
remote storage every hour, forever, no matter how large the file cache is.
   
   This PR adds an opt-in session variable, 
`enable_file_cache_for_insert_source` (default **false** — existing behavior is 
unchanged byte-for-byte). When enabled, the insert source scan uses the normal 
cache queue. The broker-load constructor path is deliberately untouched (no 
ConnectContext, genuinely one-shot).
   
   Design notes: we considered conditioning on the *target* catalog instead of 
a variable, but the pollution question is a property of the **source scan's 
reuse pattern**, not the target — a variable lets the operator state that 
intent directly. Automatic frequency-based promotion between queues would be 
the ideal long-term answer; that's out of scope here.
   
   Measured in production (recurring hourly ETL over Iceberg external tables, 
280GB file cache per BE): after enabling, the ETL account's remote-read rate 
dropped ~8x within hours (23.5 GB/h -> 3 GB/h), byte-level cache hit rate rose 
from 64% to 78% and climbing, and fleet block hit-ratio gained ~5pp.
   
   ### Release note
   
   New session variable `enable_file_cache_for_insert_source` (default false): 
when enabled, source scans of INSERT ... SELECT / CTAS use the normal file 
cache queue instead of the disposable queue.
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [x] No need to test or manual test. Explain why:
         Behavior is opt-in and default-off (existing behavior byte-identical). 
Manually verified in a production deployment: with the variable enabled, insert 
source scans populate the normal queue (`normal_queue_cache_size` growth, 
disposable evict flatline in BE bvars) and remote reads drop as described above.
   
   - Behavior changed:
       - [x] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [x] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
         Will add the session variable to the docs site once the approach is 
confirmed by reviewers.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   


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