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

Batch Apex - Runs execute() in Parallel

While trying to debug some of my batch apex, i'm noticing that batches can run in parallel, whereas I used to think they always ran in sequence.


I have a batch job, that ends up consisting of 4 batches, i.e. 4 calls of execute().  Let's call the batches A, B, C, and D.  Their times of execution are noted below.


A runs from 14:51:16.017 to 14:51:16.067
B runs from 14:51:17.019 to 14:51:17.148
C runs from 14:51:17.019 to 14:51:17.108
D runs from 14:51:17.022 to 14:51:17.259

 These times are taken from debug logs, and you can see that B, C, and D run in parallel.


I was under the impression that these batches run serially.  Infact, the following post says that as well:


Filed a Case to ask this question, and got this response from Tech Support:
1. Is it possible for the execute() method to be running more than once at the same time? (I've already confirmed that the batch job was launched only once.)

All execute methods for batches within a batch job are synchronous so they will not "trip" over each other.

[posted at:]


I'm hoping that this is true, that somehow you can have the batches run in sequence, but my experience above says otherwise.  Aftering performing timings with Database.stateful, I see that has no effect on the parallel execution of execute().


Anyone have any input on this topic?  Should I rewrite my batch job so that batches are not dependent of other batches?  Ideally, i'd like the batches to execute sequentially.




I run many batch jobs in my system and have never seen this behavior. Perhaps the jobs are being run sequentially, but on different servers whose clocks are slightly off. I would open a case with support to investigate this.

Julian Depetris ChauvinJulian Depetris Chauvin
Hi. I'd like to know if batch's chunks run in paralel or in sequence. Can anyone confirm? Thanks.