1

I am upserting some data using dataloader. The csv file has around 50,000 records in it which I am upserting. I have a trigger on the object where I am upserting these records.

My question -> I know that the 50,000 records will be broken down into chunks of records ( from 200 to 2000) based on what number specified in the dataloader. I would like to know if each batch of records has 200 records , so 50,000/200 = 250 batches each has 200 records. How does the trigger behave in this case. Will the governor limits be calculated until all the 250 batches are completed( 250 batch = 1 transaction) or there will be separate governor limits for each batch of records(250 batch = 250 transactions)?

  • 1
    250 batch = 250 transactions! – Cloud Ninja Aug 24 '16 at 5:32
3

The governor limit will be refreshed for each transaction .

Your Trigger needs to ensure that for 200 record set you are not doing below in a single transaction

10K DML rows ,

Fetching more than 50K records ,

Doing more than 150 DML (This is not possible unless you have DML inside loop or there is a dependent object that triggered and you have chain of triggering events ) ,

Doing more than 100 SOQL statements (Again this can happen if you have query inside FOR loop)

Transaction here may include any other trigger or workflow that triggered due to DML of the triggering object

  • Thanks for quick response. What if my trigger calls a batch class which generates a scope of more than 50,000 records and in execute method changes the value of a field 'xyz' in those records and update all the records. WIll it hit the governors limit? – SfdcBat Aug 24 '16 at 5:39
  • Batch executes in asynchronous mode so it's part of different transaction or thread .Again if you pass 50000 rows in start method then you won't hit any limits as execute will chunk it to many transactions – Mohith Shrivastava Aug 24 '16 at 5:41
  • Got it! Thank you! – SfdcBat Aug 24 '16 at 5:42
  • 1
    In short everytime you break the thread you start with fresh limits – Mohith Shrivastava Aug 24 '16 at 5:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.