Apex CPU time limit exceeded when a batch is run
baobao917 opened this issue · 4 comments
I've created this issue b/c it is occurring more frequently now. Anytime I have to run an update on a batch of records of the rollup's child object, ApexRollup gets an Apex CPU time limit exceeded error. It occurs if it occurs in a scheduled flow or if I do a batch update of records directly. In my experience, I'm getting the error pretty consistently on any batches exceeding 70 (whereby the update operation isn't doing anything complicated...just populating a field value).
Discussed in #519
Originally posted by baobao917 October 8, 2023
I have a simple scheduled flow that runs that updates a collection of records. It is a very simple flow just updates one field on each of the records in the collection. It has previously worked without any issue.
These records are the child object in an Apex Rollup. Now that I've introduced the flow trigger on the child object, it has pushed the transaction time beyond the APEX CPU limit. I've tried to create the apex rollup flow trigger as asynchronous but it appears that it is not possible. Do you have any suggestions?
@baobao917 I've managed to reproduce this issue this morning. I have some ideas on how to streamline the process to make these updates from Flows more performant.
@baobao917 I'm nearly finished with the current round of optimizations, many of which I've pre-deployed to your sandbox. Hopefully I'll be able to wrap up this version today or tomorrow.
Thanks @jamessimone ! I saw v1.6.5 was related to this. Do you have an idea of what the batch size improvement should be now? The full 200? I saw that you noted that this was the low hanging fruit and that possible future enhancements possibly are coming as well....looking forward to it!
@baobao917 You can check out the Test - Apex Rollup Bulk Update James
flow I made in your sandbox - that test was with ~100 records. I can expand the date range that flow is using to ensure higher record counts continue to work.