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
punit tyagi 12punit tyagi 12 

Let’s say you want to process 1 million records using Batch Apex.

 Let’s say you want to process 1 million records using Batch Apex.

batch size is 200

a.)then how many batch are created.

b.) how many transaction are created.

c.) how many times batch are call

d.) how many times finish execute method are executed.

 

VinayVinay (Salesforce Developers) 
Hi Punit,

If you want to process 1 million records using Batch Apex. The execution logic of the batch class is called once for each batch of records you are processing. Each time you invoke a batch class, the job is placed on the Apex job queue and is executed as a discrete transaction. 

> Every transaction starts with a new set of governor limits, making it easier to ensure that your code stays within the governor execution limits.
> If one batch fails to process successfully, all other successful batch transactions aren’t rolled back.

Please mark as Best Answer if above information was helpful.

Thanks,
Vijay NirateVijay Nirate
Hi Punit,

below are the answers to your questions.

considering batch size as 200 .
a.)then how many batch are created. --> what  do you mean by batch created, 1 millions records divided by 200 will create 5000 batches that will run execute method 5000 times.
b.) how many transaction are created. --> one trasaction for start method, 1 million / 200 = 5000 trasactions for execute method and one trasaction for finish method.
c.) how many times batch are call  ---> as explained start will be called one time, execute method will be called 5000 times and finish method will be called only once.
d.) how many times finish execute method are executed.  --> finish method always executes only one time after finishing all the batches.

Thanks,
Vijay Nirate
punit tyagi 12punit tyagi 12
This is not the appropriate question