What happens when we use Database.insert to insert more than 10000 records with allOrNone set to False? Are only the first 10000 ones inserted?

  • List can insert 50,000 records at a time?
    – shyam
    Oct 13, 2021 at 16:15

3 Answers 3


Governor limits are checked before any rows are modified, so the allOrNone flag has no effect. Simply trying to modify a record past the 10,000th row will automatically result in a governor limit being thrown, and the entire transaction fails. If you think you might hit a governor limit, it's important that your code check using the Limits beforehand.

  • Thanks, I was just wondering about what would happen, as setting allOrNone to false should allow insertion of 10000 records because they are not causing the exception (LimitException is an exception after all), the 10001st and onwards will. But since governor limits are checked first, I guess this allOrNone flag doesn't even come into consideration. May 14, 2017 at 13:35

The Answer of your questions are as follows : -

  1. If you try to insert the records with in 10000 limit, then if one record fails, the remainder of the DML operation can still succeed.

  2. but if you try to insert the record above 10000, say 15000 then it will throw an error like "System.LimitException: publish:Too many DML rows: 10001".salesforce won't allow you to insert any record.

  • How to overcome this situation? which has 10000+ records?
    – user7601
    Dec 7, 2017 at 13:23

As per the documentation:

The optional allOrNone parameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed.

So if you are inserting 10000 records and lets say 5000 failed, the other 5000 might still insert.

  • 1
    My question is, there can be upto 10000 rows in a DML operation. So what if I am trying to update 15000 in the same transaction? May 13, 2017 at 13:15

You must log in to answer this question.

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