7

People tend to lump "batch" and "scheduled" Apex together, given that the former is often invoked from the latter. The way they're talked about, it's easy to think that they are both examples of asynchronous Apex.

This made me wonder, is scheduled Apex, all by itself, considered synchronous or asynchronous? More importantly, does scheduled Apex use synchronous or asynchronous governor limits?

7

Scheduled Apex uses synchronous governor limits.

To confirm this, I created and scheduled an Apex class with one purpose: executing SOQL queries until hitting the governor limit. The job failed (as expected) with the reason, "Too many SOQL queries: 101".

Screen shot from the Apex Jobs monitoring page, showing the "Too many SOQL queries: 101" exception message

As of Winter '15, the synchronous limit on SOQL queries is 100, and the asynchronous limit is 200. Failing at query #101 demonstrates that scheduled Apex uses synchronous governor limits.

  • note that scheduled apex is frequently used to launch Batchable Apex classes which will execute under async limits – cropredy Nov 8 '14 at 2:27
  • Exactly right, @crop1645! That's why I think a lot of people assume that both scheduled AND batch Apex are async. I wanted to get confirmation that scheduled Apex was synchronous when it was running "all by itself". :-) – Vivek M. Chawla Nov 10 '14 at 2:28

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.