1

Salesforce docs says: "Each upsert statement consists of two operations, one for inserting records and one for updating records. Each of these operations is subject to the runtime limits for insert and update, respectively. For example, if you upsert more than 10,000 records and all of them are being updated, you receive an error."

Link: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_limitations.htm

Does this mean if I do DML of 12,000 record where 2000 will be inserted and 10,000 records will be update will not give too many dml rows exception.

Or will it means if I do DML of 10,000 record with 8000 as insert and 2000 as update then will it give exception of too many dml rows?

2

DML limits are per transaction limits. For example see below code:

System.debug(' limit dml rows ' + Limits.getDMLRows());
Account a = new Account();
a.name = 'testing --- overflow';
insert a;

List<Account> accs = [ Select Id, name from Account limit 1];
accs[0].name = 'testing..overflow';
update accs;

System.debug(' limit dml rows ' + Limits.getDMLRows());

It counts as 2 DML rows. Similarly if you will use upsert statement it will also count 2 DML rows.

So if you are exceeding total DML rows (insert + update + delete) in one transaction it will throw exception.

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.