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.

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

1 Answer 1

6

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.

2
  • 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. Commented Sep 17, 2019 at 4:08
  • @user2598808 Sounds erroneous. As far as I'm aware, validation rules don't use any CPU time.
    – sfdcfox
    Commented Sep 17, 2019 at 12:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .