+ Start a Discussion
penchala rajupenchala raju 

what is bulkifying dml

pconpcon
Bulkifying dml more deals with making sure that you do not do DML inside of loops.  For example

BAD
for (Account account : accountList) {
    insert new Contact(
        AccountId = account.Id
        LastName = 'tester'
    );
}

BETTER
List<Contact> contacts = new List<Contact>();

for (Account account : accountList) {
    contacts.add(new Contact(
        AccountId = account.Id
        LastName = 'tester'
    ));
}

insert contacts;