We are facing issue with the Maximum CPU Time in our Sandbox and Production.
Here is the scenario:
We have a visualforce page which allows to send email to contacts(working fine for less than 500 records), for every email the set activity history is true, which creates task against each contact which is a salesforce Standard feature.There's no DML in sendemail logic, nor we have any trigger on Task. Still when we see the debug log, the Maximum CPU Time exceeds 10000* limit.
Our code is all in managed package, and all queries, statement scripts time should have been calculated in the Managed package Limits, but it seems that it is being calculated and show in Default limit.
- Salesforce task creation seems NOT bulk as I see N invocations if there are N contacts (I created sample task trigger to verify this and trigger was called N times for N contacts) ?
- Does salesforce creating task which executes its own backend code also counted in CPU Time?
- Why email send is eating so much CPU time?
Please advise on what needs to be done to handle and overcome CPU timeout issue.