I had a scenario , wherein I am updating 20k + records using a batch apex for a object called - A. There is a after insert/after update trigger written on the same object, which is used to update some values in another object - B. In this process, its hitting the 10001 DML limit error from the trigger. Batch is working fine and the trigger is also bulkified.
To resolve this issue, I took the logic of trigger out and called it from a scheduled class and queued it after 1st batch apex that I had for object A.That is , once object A is updated using Batch 1, Batch 2 will start processing and will update two. This approach is working fine and only 2 DML are issued for 2 updates here.
Now, my question is, why the 1st approach of batch+ trigger is hitting DML limit, is the trigger getting invoked for each of updated happened using batch seperately? Kindly clarify my doubt. Thanks