I have a batch that creates a record depends on the condition.

String query = 'SELECT Id, Location_Number__c, Brand_Code__c, ShippingPostalCode, Inn_Code__c, Brand_Group_Code__c, Soft_Goods_Actual_Complete_4__c, Soft_Goods_Actual_Complete_3__c, Soft_Goods_Actual_Complete_2__c, Soft_Goods_Actual_Complete_1__c,  Soft_Goods_Due_4__c, Soft_Goods_Due_3__c, Soft_Goods_Due_2__c, Soft_Goods_Due_1__c, Proposed_License_Term__c, ShippingCity, ShippingState, ShippingStreet, ShippingCountry, Hotel_Status__c, Current_Brand__c, Growth_Room_Count__c, Major_Account__c, Phone, Previous_Brand__c, Name FROM Account WHERE RecordType.Name = \'Hotel\' AND License_Expiration_Date__c!=null AND Brand_Code__c!=null AND Soft_Goods_Due_1__c!=null'

global Database.QueryLocator start(Database.BatchableContext BC){

    return Database.getQueryLocator(query);


When limiting the query to 200, it creates a 1 job process but when I didn't limit it, it creates 6 job processes. Is this the nature for batch?

Does the batch per job process checks again the query from the start or the list or not?

  • Just fyi you do not need to use string queries. It would be much easier to read actually if you did a static query. That's when you just put the SOQL directly within square brackets ([SELECT ... FROM ... WHERE ...]). Then you can use multiple lines, don't need to escape your strings, etc.
    – Adrian Larson
    Aug 8, 2017 at 11:12

1 Answer 1


Yes this is the nature of Batch. Batch chunk size vary from 1 to 2000(number of records which can process in single transaction).

By default it process records in size of 200.

From the Apex Developer Guide (Using Batch Apex):

Each execution of a batch Apex job is considered a discrete transaction. For example, a batch Apex job that contains 1,000 records and is executed without the optional scope parameter from Database.executeBatch is considered five transactions of 200 records each.

An optional parameter scope. This parameter specifies the number of records to pass into the execute method. Use this parameter when you have many operations for each record being passed in and are running into governor limits. By limiting the number of records, you are limiting the operations per transaction. This value must be greater than zero. If the start method of the batch class returns a QueryLocator, the optional scope parameter of Database.executeBatch can have a maximum value of 2,000. If set to a higher value, Salesforce chunks the records returned by the QueryLocator into smaller batches of up to 2,000 records. If the start method of the batch class returns an iterable, the scope parameter value has no upper limit. However, if you use a high number, you can run into other limits.

You must log in to answer this question.

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