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
deepak_naikdeepak_naik 

Bulk Query to extract more then 1000 records

Hi

Had a very primitive question regarding the number of batches that are created using the Bulk API for "QUERY" Operation.
The BULK API limits says that we can have the maximum records that can be returned from a batch in a bulk query request is 10000 records. If I send in a query in a batch request to the bulk API and the query result is 50000 records, with the createJob() method take care of creating the 5 batches that will return each 10000 records.

When I do say "job = connection.createJob(job); batchInfo = connection.createBatchFromStream(jobInfo, is);" where my input stream is say "Select Id, Name from Account" which should returns 50000 records, how do I get the information of the each batch that is created

Or, is it that I should create the batches such that the number of records does not exceed 10000 for each batch. If yes, then I can get the result for the first 10000 records, but how do I get the result set for the subsequent records.

Regds,
Deepak
Best Answer chosen by deepak_naik
UC InnovationUC Innovation
The 10,000 limit does not apply to queries.  See https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_concepts_limits.htm.  It says "Bulk batch sizes are not used for bulk queries."  The bulk quey will return a file size up to 1GB, with max of 15 files.  So, if you have 50,000 records, it'll return everything at once.

All Answers

deepak_naikdeepak_naik
Hi

Thanks, but the link only provides the information during INSERT operation, but my query was for QUERY Operation.
For INSERT, it is expected that an application wants to insert data into Salesforce, then the batches needs to be initiated by the application itself
But that will not be the case for QUERY operation, as the application will not know, how many records are in Salesforce to be extracted (the number of records on Salesforce side may be dynamically changing due to othe  parallel insert or delete operation)

Sill, I am not sure who creates the batches for QUERY operations as per the number of records, is it Salesforce or the application needs to create it

Regds,
Deepak

 
deepak_naikdeepak_naik
Hi

Even if I try to modify my query to return the next 10,000 records after the first 10,000 records, such as "Select Id, Name from Account LIMIT 10000 OFFSET 10000", the Bulk Query Job throws an error saying " Failed to process query: FUNCTIONALITY_NOT_ENABLED: SOQL OFFSET clause is not supported in Bulk Query'"

Regds,
Deepak
UC InnovationUC Innovation
The 10,000 limit does not apply to queries.  See https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/asynch_api_concepts_limits.htm.  It says "Bulk batch sizes are not used for bulk queries."  The bulk quey will return a file size up to 1GB, with max of 15 files.  So, if you have 50,000 records, it'll return everything at once.
This was selected as the best answer