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
NDangNDang 

Does batch class fetches all records at once from database or fetch them according to chink size

Does batch class fetches all records at once from database because I am not able to get the updated values in records fetched in batch.

My batch class runs on all Accounts where isDuplicate= false and finds duplicate account and mark its isDuplicate to True. Now, since my query has 'isDuplicate= false' so if a Account records is updated during the first chunk run (chink size is 500) and its isDuplicate field is set  to True, so will this Account be fetched in subsequent chunks?
 
Om PrakashOm Prakash
Yes.  A batch Apex job fetch all records at once in start method of batch (up to 50 million records) and process in chunk as per your batch size.
 
NagendraNagendra (Salesforce Developers) 
Hi Dang,

1) The start method of a batch Apex class collects the records or objects that will be processed.
2) The execute method picks up batches of these records and does the bulk of the processing.

For more information may I suggest you please check below blog post which might help you. Please let us know if this helps.

Kindly mark this as solved if the information was helpful.

Thanks,
Nagendra