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
raviii tejaraviii teja 

why we use batch apex

Ashutosh Tripathi 9Ashutosh Tripathi 9
Ravi,
Where we have to deal with the complex and long running process and have to deal with the huge amount of data there we use batch apex.
It handeled the governer limits in such scenario and breks up our large amounts of records into small data chunks, whihc becomes easy to process.

It has three methods.
Start Method -- Gather all the data, or you can say prepare the data for execution.
Execute Method -- Execute your data with the logic. Suppose you have 1000 records then these 1000 records prepared by the START method and pass it to the execute method and execute method process them by making of each of 200 records, so your execute method will execute 5 times in this case.
Fisnish Method -- This mehod will execute once all your 1000 records will be processed. You can leave it empty or write any logic here whihc you want be done after processing all the records like sending email alerts.

Hope this would help.