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
Anupama@28Anupama@28 

Bulk API query batch size limit.

As per I know when I am fetching the records from salesforce using bulk API , each batch contains 10,000 records.
Currently I have more than 5,00,000 records in my salesforce enterprise org, but it is creating only one batch  and using that batch it is retrieving all the records . What may be the reason? .

I have done the following steps :
1 : Created a job using sessionId
2 : added a batch to the job and got the following output

output :
----------

<?xml version="1.0" encoding="UTF-8"?><batchInfo
   xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<id>75190000001NuAWAA0</id>     -----> Only one batch is created for more than 5,00,000 records
<jobId>75090000000jZVAAA2</jobId>
<state>Queued</state>
<createdDate>2014-03-10T05:35:49.000Z</createdDate>
<systemModstamp>2014-03-10T05:35:49.000Z</systemModstamp>
<numberRecordsProcessed>0</numberRecordsProcessed>
<numberRecordsFailed>0</numberRecordsFailed>
<totalProcessingTime>0</totalProcessingTime>
<apiActiveProcessingTime>0</apiActiveProcessingTime>
<apexProcessingTime>0</apexProcessingTime>
</batchInfo>

3 : Retrieved the batch result using the query : Select Id from Case , It is returning all the 5,00,000 Ids.

Please help me to get to know the things clearly.
Also let me know if is there any way to set the batch size manually.

Thanks
Anupama
Ashish_SFDCAshish_SFDC
Hi Anupama, 


The reason may be the Query is hitting Execution server only once, which should be iterative in hitting server with 10'000 multiple times. 

The code should be iterative in such a way that every time it hits the Server it should go with 10000 records at a time until the entire records are retrived / filtered etc. 

See the code Samples in the link below, 

https://developer.salesforce.com/page/Apex_Code_Best_Practices


Regards,
Ashish