Bulk API Query
Use bulk query to efficiently query large data sets and reduce the number of API requests. A bulk query can retrieve up to 15 GB of data, divided into 15 files of 1 GB each. The data formats supported are CSV, XML, and JSON.
Bulk API query limits are described in Bulk API and Bulk API 2.0 Limits and Allocations in the Salesforce Developer Limits and Allocations Quick Reference
-
How Bulk Queries Are Processed
The bulk query workflow begins when you create a bulk query job and add one or more batches to the query job. When a bulk query is processed, Salesforce attempts to execute the query. If the query doesn’t execute within the standard 2-minute timeout limit, the job fails and a QUERY_TIMEOUT error is returned. In this case, rewrite a simpler query, and resubmit the batch.
-
When you add a batch to a bulk query job, the Content-Type in the header for the request must be
text/csv,application/xml, orapplication/json, depending on the content type specified when the job was created. The actual SOQL statement supplied for the batch is in plain text format. -
Use the primary key (PK) chunking request header to enable automatic PK chunking for a bulk query job. PK chunking splits bulk queries on large tables into chunks based on the record IDs, or primary keys, of the queried records.
-
Walk Through a Bulk Query Sample
This code sample uses cURL to query several account records.
-
Walk Through a Bulk Query Sample Using PK Chunking
This code sample uses cURL to perform a bulk query with PK chunking enabled on several account records.