I want to build an update trigger on a rollup summary field.
Say I have a parent record A, A have 1000 children records linked with a Master-Detail relationship.
1.First Operation: delete 1000 records, if the code is like
List<Child__c> children = [select id from Child__c where parentid = A.Id];
delete children;
How many times would the update trigger on parent record A run?
Is it 5? What if the second 200 batch is being deleted when the first update trigger is running? I'm confused with the execution order and the events start&end order.
2.Second Operation: insert 1000 child records from data loader or any external app.
How many times would the update trigger on parent record A run? Is it 5? Is it similar to the delete operation?
Thanks
Update
The Roll up summary field is a "SUM" of it's children records field num__c which has a number type.
The question assumes the num__c field of the deleted&inserted children records have value on this field.
The question also specified 1000 child records belongs to a same parent record
Rollup Summary
field? Are you performing aCOUNT
operation?SUM
?