# How does Flow bulkification manage large record collections to prevent governor limit exhaustion?

**Topic:** Admin · **Difficulty:** Medium · **Tags:** Admin, Flow Bulkification, Governor Limits

Read it on the site: https://www.forcechallenges.com/interview-questions/how-does-flow-bulkification-manage-large-record-collections-to-prevent-governor-limit-exhaustion

## Answer

**Basics:** Governor limits are per transaction and shared with Apex: 100 synchronous SOQL queries, 150 DML statements and 10,000 DML rows. A record-triggered flow handling a data load of 200 records must not run a query or DML per record. Flow's engine groups interviews so a Get Records or Create Records element runs once for the whole batch, but logic you place inside a Loop does not get that protection.

**How it works:**
1. The platform bulk-processes record-triggered interviews: for a batch of 200 inserted records, each element is executed for all interviews together where possible.
2. Inside the flow, collect work into a record collection variable using Assignment within the loop.
3. After the loop, run one Create/Update/Delete Records on the collection.
4. Use Get Records before the loop and filter in memory with Decision or Collection Filter/Sort instead of querying per iteration.
5. Prefer before-save record-triggered flows for same-record field changes: they need no DML and are far faster.

**Advanced / deep dive:** The classic failure is Get Records or Update Records inside a Loop, or calling a subflow or invocable Apex that itself queries inside the loop; each iteration consumes SOQL/DML, hitting 100 SOQL or 150 DML errors ("Too many SOQL queries: 101"). Per-interview limits also apply: at most 2,000 executed elements per flow interview. Because flows, triggers and legacy automation share one transaction, ten record-triggered flows plus Apex on the same object add up; use Flow Trigger Explorer and Trigger Order to see the combined load. Collection operations (Collection Filter, Collection Sort, Transform) reduce loops. For large volumes, move work to Scheduled-Triggered Flows (batches of 200), asynchronous paths ("Run Asynchronously"), or Apex Batch. Invocable Apex called from flows receives a List of inputs and must be bulk-safe itself.

**Code / config example:**
```
Record-Triggered Flow (After Save, Case, Created)
1. Get Records: Accounts WHERE Id IN {!AccountIdCollection}     (once, before loop)
2. Loop over {!$Record_Collection or related collection}
     Assignment: set {!acct.Open_Cases__c} ; Add {!acct} to {!AccountsToUpdate}
3. (after loop) Update Records: {!AccountsToUpdate}              (once)
Anti-pattern: Update Records element inside the loop.
```

**Hidden gotchas & must-remember points:**
- Flow is bulkified by the engine, not by magic: loops that contain data elements are not.
- Limits are shared with all automation in the transaction, including Apex triggers.
- A before-save flow cannot create or update other records.
- 2,000 elements per interview, 100 SOQL sync, 150 DML.
- Debug runs process one record, so bulk problems appear only in data loads; test with 200 records.
- Fault paths roll back the transaction unless handled.

**Best practice:** Query once, loop in memory, write once, and test every record-triggered flow with a 200-record load.

---
Source: ForceChallenges · last updated 2026-11-02
