Sunday, 11 December 2022

Apex CPU Time Limit

 Usually, all the developers came across this term while developing some complex logic in apex. Apex has System.LimitExceptions and "Apex CPU time limit exceeded" is one of them.


Apex CPU time limits:

1] Synchronous Limit - 10,000 milliseconds (10 Seconds)

2] Asynchronous Limit - 60,000 milliseconds (60 Seconds)


To resolve this exception we can follow below points:


1] Avoid Multiple automation on a Single Object

2] Trigger Framework

3] Avoid multiple Validation Rules

4] Using Map based query

5] Use Async Apex (Future, Batch, Queueable, Schedulable)

6] Aggregate SOQL usage

7] Avoid Nested For loop

8] Avoid using process builder

9] Use Return Early Pattern


What is not counted for Apex CPU Time Limit?


1] Database operations like database operation for DML, SOQL and SOSL.

2] Wait time for Apex Callout

3] Aggregate SOQL


No comments:

Post a Comment