0

I was recently trying to create a set<id> myset, and then perform around 600 .add('...id...') calls, and finally select some records based on myset values.

When trying to execute it it was always showing, without giving me any reason.

Execution failed

I noticed that the maxim number of ids I was allowed to add was around 250-300.

1) Is there a known limit in terms of the execution time in in Asynchronous Apex ? (I know that in synchronous Apex is around 10 seconds, but never the less adding 600 items to a list shouldn't take anywhere close to 10 seconds).

2) How long does a .add() call take?

1 Answer 1

1

1) We have 60,000 (60 Sec) CPU time limit in asynchronous process.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm

2) There is no specific time for time taken by .add() method and it can take n number of values (no limit).

1
  • 2
    Adding an item into a set in apex is a constant-time operation (~O(1) complexity for those who know about big-O notation). We know this because the docs say that an apex Set is really a Java HashSet in the back-end. Each individual call to add() takes some time which counts towards the CPU time governor limit, but the time each call takes is so small that it usually takes tens of thousands of calls to add() before you can see a clear effect on the reported CPU time used.
    – Derek F
    Commented May 12, 2016 at 14:58

You must log in to answer this question.

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