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
Yeluri Venkata Sai KrishnavamsiYeluri Venkata Sai Krishnavamsi 

How to parallelize reading CSV result from Bulk API V2?

After reading the job result with maxRecords = 10000, the API sends Sforce-Locator in the response headers which can be used to fetch the next batch of records. 
To read 'n' batches in parallel I need 'n' Sforce-Locators beforehand.
  • Is there a way to get these 'n' locators given the maxRecords without actually waiting to download the content?
  • Is there a limit on the number of concurrent connections to this result API?  If not, Can I trigger any number of GET requests in parallel to download the result without facing connection reset issues from the server?
sravani proddatur 10sravani proddatur 10
Hi Yeluri,

An example where this can be seen is, when retrieving 100K records with a Bulk API v2 Query job.  Use locator as 0, 10000, 20000, ..  90000 and MaxRecords set to 10000, the time taken to retrieve each of the 10 sets of results may vary. 
 
The Bulk API V2 query job results is not stored in a single file, it could be stored across multiple files. So, while retrieving the results using Locator and MaxRecords, the time taken to retrieve query result may not be consistent. This is usually seen when the total number of records retrieved with the Bulk query job is of a large size. 

If this Solution is helps you Plz mark as the best Answer,
Thanks.
Yeluri Venkata Sai KrishnavamsiYeluri Venkata Sai Krishnavamsi
Thanks for the response.
In the rules and guidelines section of this documentation here (https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/query_get_job_results.htm), they suggested to use the locator value only from the response headers. Moreover, the Sforce-Locator values from the response headers are something similar to these MTAwMA, MTA, etc
Does Salesforce expose any other API to just get the locator value given the maxRecords without downloading the data?