Newer Version Available

This content describes an older version of this product. View Latest

Use Compression for Bulk API 2.0 Query Responses

For query jobs, Bulk API 2.0 can compress the response body, which reduces network traffic and improves response time.

If encoding is enabled for Bulk API 2.0 Query job responses, there is a significant improvement in performance of query result downloads. This not the total query time, but a reduction in the time to download the results.

Tip

Responses are compressed if the client makes a request using the Accept-Encoding header, with a value of gzip. Bulk API 2.0 compresses the response in gzip format and sends the response to the client with a Content-Encoding: gzip response header. If a request is made using the Accept-Encoding header with a value other than gzip, the encoding type is ignored, and the response isn’t compressed.

As an example, if a Get Results for a Query Job request is made with the Accept-Encoding: gzip header, the response looks something like:
1HTTP/1.1 200 OK 
2Date: Tue, 09 Oct 2012 18:36:45 GMT 
3Content-Type: text/csv; charset=UTF-8 
4Content-Encoding: gzip 
5Transfer-Encoding: chunked
6
7...compressed response body...

Bulk API 2.0 follows the HTTP 1.1 standards for response compression, as described in Using Compression. Most clients automatically support compressed responses. Even though you request a compressed response, the REST framework sometimes doesn’t send back the response in a compressed format. Visit https://developer.salesforce.com/page/Tools for more information on particular clients.