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
fundooMentalfundooMental 

What does mean by trigger can process 200 records at a time

This might sound silly but I need to know the exact context of this.  When we say "When a trigger fires it can process anywhere from 1 to 200 records " Then what does processing means here?

For example I have a trigger which fires on Object A (before insert ) and it inserts 200 records of Object B. So would this insert DML operation also be called record processing?

Best Answer chosen by fundooMental
bob_buzzardbob_buzzard
Processing means that the trigger can receive up to 200 records at a time to apply your custom logic to.  So if you are (simply example) setting the name of an opportunity to the account name and close date, you couldn't assume you would only ever receive a single record at a time.  While that will be the case when a user updates a record in the UI, if you load in several thousand records through the Apex data loader, then these will be broken up into 200 record chunks.  Your trigger would therefore need to iterate through all of the records passed to it and apply the custom logic to each one.

The reason there is focus on this is that you can't rely on executing SOQL or DML for each record, as you will breach governor limits.  Instead you have to use lists/maps to retrieve/update the associated information for all your records in one go, aka bulkifying.

All Answers

bob_buzzardbob_buzzard
Processing means that the trigger can receive up to 200 records at a time to apply your custom logic to.  So if you are (simply example) setting the name of an opportunity to the account name and close date, you couldn't assume you would only ever receive a single record at a time.  While that will be the case when a user updates a record in the UI, if you load in several thousand records through the Apex data loader, then these will be broken up into 200 record chunks.  Your trigger would therefore need to iterate through all of the records passed to it and apply the custom logic to each one.

The reason there is focus on this is that you can't rely on executing SOQL or DML for each record, as you will breach governor limits.  Instead you have to use lists/maps to retrieve/update the associated information for all your records in one go, aka bulkifying.
This was selected as the best answer
fundooMentalfundooMental

@bob_buzzard Thanks for the reply friend. Indeed I understand these governor limit limitaions. So Processing means I can say, anything like validation, updation etc that my trigger code would do on the records.

Now from the example that I have given, would inserting the 200 sObjects records of Object type B (see in the question) would also be called processing?

RishavRishav
HI gyanendra,
                          ofcourse, you are right.Inserting the 200 records of object type B will also counted.Not only insertion it can be any DML operation that will be process by trigger will process 200 records at a time.

Thanks
Rishav
bob_buzzardbob_buzzard
Yes, any logic that you apply to the record would be considered processing, regardless of what that results in. You could substitute handling,validating,inserting,transforming for processing, 
fundooMentalfundooMental
Thank you all for clearing the cloud :)