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
sornasorna 

Batch Apex - Process batches in the same order as received from start

I am running a batch apex which involves huge amount of data. The start method queries the data by ascending order of created date and sends it to execute method. But I found in the Apex reference guide that the batches of records are not guaranteed to execute in the order they received from the start method. This messes up the processing of data as I want them to be processed in the ascending of created date. So, is there a way to force the execution to be processed in the same order? Or any suggestions would be appreciated.

 

Thanks in advance,

Sorna

Starz26Starz26

Does subsequest batches rely upon the results of the first batch? If so can you provide a small bit of explination as to why the new records need to be processed first and maybe we can assist.

 

As it stands I do not believe there is a way to order the batches in the order called by the query locator, although generally they should fire around the same time.