I have a huge process running, but I haven't used nested loops anywhere. I have a process which iterates 12,000 records. I was paginating this 12000 record list as smaller pages( I know its wrong)

I got two types of errors,

CPU Time limit exceeded


time limit exceeded

What's the difference? And how do i go about mitigating this? and pagination?

  • 3
    post your code here
    – sfdc
    Oct 6, 2014 at 15:52

1 Answer 1


"CPU time" is the time taken by your code to execute, excluding database transaction time, callout time, etc. It is 10,000 ms for synchronous transactions.

"Time limit exceeded" means your transaction waits for more than 120 seconds and your action was not executed within time frame. For example, you are waiting for response on call from webservice and your external system fails to respond within 2 minutes, or you have many rows to retrieve from a table with huge volume and the query times out.

Consider some options to find cause:

1) Data volume of your object that's being queried. Consider indexing to reduce time out issues.

2) Remove unnecessary for loops and make your queries streamlined. Use inline SOQL instead of collecting in collection and then looping. This will help in CPU time reduction.

  • Sorry. I misread your answer the first time (thus the -1), then I was locked in. I cleaned up the answer to avoid future mis-votes from other visitors.
    – sfdcfox
    Oct 6, 2014 at 17:01
  • Sorry i was travelling and was answering through phone.Thanks for clean up. Oct 6, 2014 at 17:27

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.