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

How to set the batch size in batch apex class?

How to set the batch size in batch apex class? pls any one help me.

janardhan mjanardhan m

You can use the Database.executeBatch(sObject className, Integer scopeSize) method to set the new  batch size.
Be sure the scopeSize should less than 200.

Database.executeBatch(sObject className, 50 ) would set the batch size to 50 instead of 200
Rahul Sangwan7341Rahul Sangwan7341
Hi viswsanath,

when you are running the batch class there you will set the size. Check the example:

ExampleBatchClass b = new ExampleBatchClass();
//Parameters of ExecuteBatch(context,BatchSize)

Please select this as Best Answer if it helps you to solve your problem.
Tejpal KumawatTejpal Kumawat
Hello viswsanath,

You need to pass like :

Your Batch Controller Name : Batch_TestController
Like you want to size : 200

then use :
Database.executeBatch(new Batch_TestController(), 200);
If this answers your question then hit Like and mark it as solution!