A user is trying to update some records in Salesforce, he is getting this error:

OrderHistory: System.LimitException: Too many DML rows: 10001.

He added that he is not able to insert 100 records at a time in Salesforce. I checked OrderHistory Apex Trigger code, took the SOQL query out of the for loop (that may be causing the governor limit hit), still no luck. Please can someone suggest how can i get rid off this error?


2 Answers 2


Your error doesn't have to do with a SOQL query in a for loop (although you really don't want that either). Your error has to do with too many records being inserted or updated at once. It sounds like the trigger has not been properly bulkified. If you have a trigger that is trying to update that many rows, you should really look into turning it into batch apex.

  • 2
    Hitting a Too many DML statements error would be due to a lack of bulkification, but in this case it's hitting the limit on total # of rows created/modified. There's some massive data editing going on here that needs more explanation. Jun 6, 2013 at 5:26

Your whole transaction can at most perform DML (run insert/update/delete) of at most 10000 records.

I suspect it's data specific - do you have lots of child objects for example? Is update of these particular records causing lots of workflows or rollup recalculations to fire?

It's really hard to advise without knowing your whole situation (probably even posting the body of trigger won't help, it'd be more of "Debug log + relationship diagram for the involved objects please".

If there are some updates that you could delay - read about @future methods. It'll also be good for the end user perception (it'll appear that the transaction has completed faster). If it really has to be in all or nothing - you might have to move your "whatever recalculation is happening" into batch Apex.

You must log in to answer this question.

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