I just got this error when trying to deploy new components to Prod. It's happening on Apex test classes that already exist in Prod, not new ones in my change set. I understand that this error relates to a new governor limit that was introduced in the Winter '14 release. What's the best approach for me to go about addressing this in order to commit my change set?

2 Answers 2


The Maximum CPU time on the salesforce servers - 10,000 milliseconds (Synchronous limit) 60,000 milliseconds(Asynchronous limit).

You may have to go in and edit and refine some of your code, This may be a good place to start.



How to code more efficient to avoid "Apex CPU time limit exceeded"?

I'm retracting what I said earlier about a query in a for loop..

"Operations that don’t consume application server CPU time aren’t counted toward CPU time. For example, the portion of execution time spent in the database for DML, SOQL, and SOSL isn’t counted, nor is waiting time for Apex callouts."

  • 2
    Query inside loop is a bad example. Queries don't count towards CPU time limit.
    – sfdcfox
    Apr 9, 2014 at 18:56
  • Opps I'll edit my post
    – EricSSH
    Apr 9, 2014 at 20:30

Please check what is consuming your CPU time.

I have posted the following in another post related to CPU time issues. So copy pasting her as I see the relevance.

I suggest to check your process time on queries and loops. Check the same in trigger as well.

add a statement before your query(s) and after it and also before the loop(s) and after them to see what is eating up most of the time. Following is the example:

Long queryStartTime = DateTime.now.getTime();

--your query statements and logic here

Long queryEndTime = DateTime.now.getTime();

--now check the time it is taking

System.debug(LoggingLevel.ERROR, 'Query time taken: ' + (queryEndTime - queryStartTime ));

You may find your problem with this. If not write back.

  • Note that you will consume extra CPU time with all this debugging.
    – Adrian Larson
    Sep 29, 2015 at 21:00

You must log in to answer this question.

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