+ Start a Discussion
Sagar KhandareSagar Khandare 

I have one question about triggers. If we insert 50k records using Data Loader on particular Object on which one trigger is Active. then how many times trigger gets fire ??

Peter_sfdcPeter_sfdc
It depends, is probably the most honest answer. 

First off, for just a simple record, with no other customizations, if you hang a trigger off it and test for executions on insert, you will see it execute once Before Insert, and once for After Insert. 

The max trigger batch size is 200. So in the case of 50k, the trigger would fire 2 times per 200 records meaning 500 invocations of the trigger ( 50,000 / 200 * 2 ). 

But, you can change the batch size in Data Loader, too, so let's say you use a batch size of 50. In that case you would have 2000 trigger invocations ( 50,000 / 50 * 2 ). 

But there's one caveat. The batch size in data loader actually limits the number of records sent to Salesforce per API request. So actually, each API request executes the trigger twice. Once for insert, and once for update, for the entire batch. 

Hope that helps.