Skip to main content
I have created a batch class to update a field value for all the opportunity records.

 

In my first org, there were only 35 total opportunity records. I invoked the batch class using following:

 

OpportunityProcessor opp = new OpportunityProcessor();

 

Database.executeBatch(opp);

 

The batch class has successfully updated all 35 records.

 

In my other org, there are total 7 lakh opportunity records. Is it possible to update all of these records at once using the above process?

 

or do I have to use Database.executeBatch(opp, 10000)?
4 answers
  1. Jul 27, 2020, 9:29 AM
    Hi Priya,

     

    First option will work. I mean without Scope parameter you may run the job and 7 Lakh records shoud get processed.

     

    By Default Scope's value is 200. It means eaech batch will process 200 records and Total 3500 batches will be submitted to process 7 lakh records.

     

    Database.executeBatch(opp, 10000) <--- Maximum 2000 can be defined. System will automatically break records in 2000 chunks.

     

    You may refer below link for more details about scope parameter:

     

    https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm

     

    Scope Parameter:

     

    An optional parameter scope. This parameter specifies the number of records to pass into the execute method. Use this parameter when you have many operations for each record being passed in and are running into governor limits. By limiting the number of records, you are limiting the operations per transaction. This value must be greater than zero. If the start method of the batch class returns a QueryLocator, the optional scope parameter of Database.executeBatch can have a maximum value of 2,000. If set to a higher value, Salesforce chunks the records returned by the QueryLocator into smaller batches of up to 2,000 records. If the start method of the batch class returns an iterable, the scope parameter value has no upper limit. However, if you use a high number, you can run into other limits.

     

     
0/9000