function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Just Code ItJust Code It 

Batch Apex vs. Apex Scheduler

Hi Everyone,

Can anyone point me to the difference between Batch Apex and Apex Scheduler at the usage level? I see difference at the programming level; however, still not sure of when to use one over the other.

 

Thank you all in advance,

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Apex scheduler would be used when you need something to happen at a particular point in time.

 

Batch apex would be used when you need to process a large number of records that would otherwise break governor limits.

 

There's no reason why you wouldn't combine them - I have a scheduled apex class that archives and summarizes the previous months data by executing batch apex.

All Answers

bob_buzzardbob_buzzard

Apex scheduler would be used when you need something to happen at a particular point in time.

 

Batch apex would be used when you need to process a large number of records that would otherwise break governor limits.

 

There's no reason why you wouldn't combine them - I have a scheduled apex class that archives and summarizes the previous months data by executing batch apex.

This was selected as the best answer
padma_2700padma_2700
Can you please share any sample code for apex scheduler using batch apex