function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GunnarGunnar 

Limit DML Rows

 

In the developer console, I get the following back ...

11:28:54:335 USER_DEBUG [708]|DEBUG|----------Limit DML Rows - 10000 Actual 1317

 

Here is the statement in the code that generates the above...

        system.debug('----------Limit DML Rows - ' + Limits.getLimitDMLRows() + ' Actual ' +Limits.getDMLRows());

The code is declaring a new list.

Rows are being added to the list.

Then the list is inserted.

 

I am NOT inserting each record individually. And there are 1317 records being inserted.

 

I'm curious why I'm racking up on the DML Limit Rows, when in fact, I'm doing one database insert... of a list that contains 1317 new records  ??

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9

So if you are taking about the advantages

  • Hitting DB is resource and time expensive. A efficient code will always try to avoid DB actions
  • Yes you are limited to 10K DML rows

All Answers

Avidev9Avidev9
Its not about the DML statement you are doing in your class. It counts all the records that were affected due to your DML.

Say you might have a trigger in your object. So when you are doing a update from your class, all the records affected due to the trigger will be counted against the limit
GunnarGunnar

Okay. Thanks.

 

I am adding new records to a new list. Then, I update the database with the list.

 

So what advantage do I get (not what advantage does Salesforce get) by doing that?

 

I could create a new object and insert each object.

 

Seems no matter what, I'm limited to 10,000, or else I batch.

 

(This is not a trigger, I'm dynamically creating records)

 

 

 

Avidev9Avidev9

So if you are taking about the advantages

  • Hitting DB is resource and time expensive. A efficient code will always try to avoid DB actions
  • Yes you are limited to 10K DML rows
This was selected as the best answer