I experienced a batch that changed (increased) the #TotalBatches during its execution.

104 total batches

enter image description here

Reload. 106 total batches

enter image description here

I experienced this year ago (see this question Total number of Batch jobs decreases during execution. Why that?) but back then it was considered a now fixed Known issues.

Is this a new symptom? Or do we have Groundhog day ;-) again?

  • 4
    Could you perhaps rephrase this question to be clear to those who are not familiar with what you mean by the reference to Groundhog day?
    – Adrian Larson
    Commented Aug 24, 2017 at 13:41
  • 1
    For me, every day is Groundhog Day. And not in a good way.
    – sfdcfox
    Commented Aug 24, 2017 at 13:58
  • 1
    Seriously -- there are people who don't get the reference to Groundhog Day? Oh, I must be getting old! ;) Commented Oct 4, 2018 at 3:49

1 Answer 1


During Apex Batch execution the Total Batches either increases or decreases as the Batch progresses with time.

Batch Class and its Execution:-

~A Batch Class has three methods from the Database. Batchable Interface that needs to be implemented, Start, Execute & Finish.

~The Start and Finish methods execute only once while the Execute methods run for No. Of Records / Batch Size times, creating an equal number of debug logs for each execute.

~Since the Batch’s Start method runs only once its queries all the criteria matching records and stores them in QueryLocator and passes records to Execute methods as per the Batch Size, so there is no possibility that if some records do not match or match the criteria after the Starts execution then its would either be included or excluded. Hence this issue does not have to do with the insert, deletion, or update of records to match the criteria.

~Run the batch job with batch size 1:

~Id batchJobId = Database.executeBatch(new ContactBatch(), 1);

After the batch job finishes check the last debug log, you will see that not all batches had been processed, internal callCount variable in the example class above has a value which is less than 1000:

  • So where do you explain Salesforce's change of mind regarding the total then?! Why do you suggest to run a batch with batch size 1? Sorry, but I don't get your answer. Commented Aug 19, 2022 at 8:16

You must log in to answer this question.

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