We have a Java API which uses Bulk API to extract records from an Object. The "select query" has a where clause, which should extract a subset of records, to honour the where clause, but we see that huge numer of batches are created on the Salesforce Server side, and many a times, the BULK API limits are hit

For example :

Number of records in the Object Account : 20000 We enable the connection and set the Pk Chunking header as , with chunk size as 2000


Select Query :

SELECT Id, Name FROM Account WHERE CreatedDate >= 2018-07-20T05:00:00.000Z"

As per the query to match the condition, the query should return only 10 records (at most 1 batch), but we see that there are 10 batches created on the Salesforce Server.

Why is there 10 batches that are created, when the number of records to be extracted is only 10 which can fit in 1 batch.

Is there any setting that can be applied, or code tuning that can be done so that only 1 batch is created on the Salesforce Server

1 Answer 1


Using a chunk size of 2000 will automatically add a filter on Id to your WHERE clause such that there are 2000 rows in each batch before any other filters in your WHERE clause are applied.

If you had 10,000 total Accounts in your org, using a chunk size of 2000 will result in five batches being created even if four of those batches will contain no results because of your filter on CreatedDate.

You must log in to answer this question.

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