Could anyone explain more what Batches of records tend to execute in the order in which they’re received from the start method. However, the order in which batches of records execute depends on various factors. The order of execution isn’t guaranteed. means? Seems like we can't be sure of returned records order or not?

  • What difference order by makes here, ultimately batch will process all the records. Commented Jun 6, 2021 at 15:50

1 Answer 1


No, that isn't quite what that section from the documentation is saying.

If you ORDER BY your SOQL query in start(), the platform does not guarantee that the execution of batches will be in the same order as the records are in the query. Say for example you order by Order_Num__c, and your records have values from 1-10, and you are running with batch size 2. Your execute() method may be called with the batches


where some of the batches are apparently out of order relative to the key on which the query was ordered. Batches are run asynchronously and their order relative to one another is not guaranteed.

  • But we can be sure that inside all chunks we will get right order, correct?
    – pincet
    Commented Jun 6, 2021 at 16:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .