I am trying to learn about governor limits in salesforce, specifically in the context of salesforce flows. Here is the context: I have written a flow that runs 'on insert' for a given object (contacts). Every time a new record is inserted, I am performing a check to see if there is an account record with a matching email address (custom field) as the email address on the contact. In essence, this is a lookup relationship, but is meant to automatically find the relationship. It then updates the new contact to associate the related account with it.

However, I am building this with the idea that a user will be uploading many (possibly thousands) of contact records with the data import wizard. I have concerns that I will reach governor limits in my flow for such a large import. However, when testing my flow after uploading a large file of test data contacts, I do not appear to hit any governor limits. The specific limit I am thinking of is where a transaction is limited to 150 DML statements. I understand that salesforce performs bulkification to combine limits for large transaction (like when uploading a lot of records) and that the governor limits apply to batches of 200 records. If this is the case, since every records in the batch of 200 is updating the contact, I would expect to have errors when uploading my large contact file (batched to 200 records, every records would contribute a limit to the 150 limit and it would fail before completing the first batch). However, I am not getting an error, so it appears that I don't understand something correctly, either how the bulkification / batching process works, or specifically regarding the DML governor limits.

Can anyone explain what I am missing here? Here is a snapshot of my flow for context. Please note that I am calling this flow from a simple flow that has the 'on insert' trigger. Thanks!

enter image description here

1 Answer 1


The Data Import Wizard processes records 200 at a time, using the Bulk API. That means that every 200 records get their own governor limits, no matter how many records you import, up to the maximum limit of however many records you're allowed to import.

The flow behavior is described in Flow Bulkification in Transactions. An Interview is created for each record in a transaction (up to 200 records), and each Interview will run until it reaches a bulkified element (Get Records, Update Records, etc), Pause element, or End element. Once every Interview reaches one of these states, those that are in a bulkified state will execute the element once using all of the data. That means that the bulkified element will use at most one resource (one DML for a DML element, one SOQL for a Get element, etc) per invocation. Paused Flows are saved and set aside, and interviews that have hit the End element will no longer be processed. All remaining Interviews will be run until they reach one of those conditions again, and the cycle repeats, until there are no more Interviews to execute.

Transaction governor limits are reset with every transaction, so from an API perspective, every up to 200 records get their own governor limits, no matter how many records you're uploading "at once." You do need to be careful in Apex code, because your transactions will be batched into groups of 200, and every 200 records will consume additional limits. For example, if you create a list of 1000 records, you'll use five times the governor limit than you would if you were using an API, since the governor limits are cumulative from the beginning to the end of a transaction; DML operations are subtransactions in the context of calling an Apex method, such as a webservice call, Remote Action, etc.

  • Thank you so much. I have really struggled finding good explanations of how this works, and this is the best explanation I have heard. I do have a follow up question: I don't fully understand what you are saying in the last section about how the limits behave in a cumulative manner. Could you elaborate on this a bit more? Are you saying that the limits for the second batch of 200 records accumulate onto the limits of the first transactions? Ultimately, if each batch of 200 records represent its own transaction, why would the limits accumulate? Apr 12, 2023 at 15:46
  • @LukeSharon e.g. Account[] accounts = new Account[0]; for(Integer i = 0; i < 1000; i++) { accounts.add(new Account(Name=''+i)); } insert accounts; will create 1000 accounts in memory, then one DML statement that will call the save procedure for every 200 records; your flows will execute five times during that one transaction.
    – sfdcfox
    Apr 12, 2023 at 15:49
  • So in this example, the save procedure is called for every 200 records, but this procedure is NOT the transaction, correct? Just to make sure I understand, it appears that you are suggesting that here, the transaction starts prior to the for loop? Apr 12, 2023 at 16:16
  • @LukeSharon If you run this code, e.g. execute anonymous, the entire code is the transaction, from beginning to end. Within it, there is one DML statement that calls your flows a total of five times. It uses ~5x the governor limits that 200 rows would use. The Bulk API, on the other hand, processes and commits 200 records at a time, and so the limits are reset each time.
    – sfdcfox
    Apr 12, 2023 at 16:25
  • Ah, makes sense. Thank you so much for your help!!! Apr 12, 2023 at 17:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .