I had 12,000 contacts in my developer org and in the Developer Console, I used a simple Execute Anonymous to delete all contacts. However, I hit a fatal error

System.LimitException: Apex CPU time limit exceeded.

I then ran the same script* in an IDE (Welkin Suite) and executed it, and it worked fine. What's strange though is that the log returns 'Maximum CPU time: 11385 out of 10000', so I would assume it would have failed.

1) Any reason the execute anon script worked fine in the IDE instead of the developer console?

2) Any idea why it worked in the IDE even though one of the log statements indicates that it went over the CPU time limit?

List Contact> contactList = [SELECT Id, Name FROM Contact];
delete contactList;
  • 2
    The CPU limit is not a hard limit. I have seen code running for as long as 12 seconds. This question may shine some light on it. Do you have triggers that are running when a contact is deleted? That could be causing your issue.
    – BarCotter
    Commented Sep 1, 2015 at 13:29

1 Answer 1


There are two factors at play here: logging levels and the CPU governor limits. On the one hand, the governor limit is flexible. I've seen it time out over 15,000 ms. On the other, the IDE and the Developer Console has different default logging levels... The maximum level debug logs can easily double or triple execution time.

Unless you really care about your logs, make sure you set them to the minimum level (none for all levels). This will allow maximum execution speed. If you time out in either case, you can try again; execution time depends on server load, so the exact same script on the exact same data might time out once, and succeed another time.

You must log in to answer this question.

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