0

I have a bulk update process which effects updates records in more than one salesforce objects like - Account, Contact, Contract , Opportunity and Oppt Line Item.

This bulk process does not update hundreds of records. But, yes - a lot of code is being executed and I get Apex CPU time limit exceeded error when there are more records being processed.

When my bulk process is run : all the triggers , process builders, workflows and validation rules get executed.

I am trying to understand how are validation rules executed - like does each validation rule run each time a save is done?

Does this effect the Apex CPU Time? If yes, I would like to deactivate some of the validation rules (over all - I have around 30 of them) which I don't need during this bulk process.

  • They do, but they're probably a small percentage of the CPU time when compared with triggers/flows/etc – Nick Cook Sep 17 at 1:38
4

Apex Triggers, Flows, and Process Builder consume CPU limits, but validation rules, workflow rules, matching rules, duplicate rules, assignment rules, escalation rules all do not count towards the CPU limit. However, there is still also a hard limit of 600,000 ms (10 minutes) for every transaction. If you're running in to CPU limits, it is most likely a combination of Triggers and Processes. Yes, validation rules are run at least once per DML operation, as noted in Triggers and Order of Execution. Having a ton of Validation Rules does not impact the governor limit directly. It's hard to verify certain scenarios, like if a trigger calls a DML operation, etc, but it's been my experience that only Apex Triggers can even trigger (no pun intended) a CPU governor limit error.

  • I was referring to this link: help.salesforce.com/… and it is mentioned that time spent evaluating the formula validation rules is considered. This confuses me. – user2598808 Sep 17 at 4:08
  • @user2598808 Sounds erroneous. As far as I'm aware, validation rules don't use any CPU time. – sfdcfox Sep 17 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.