Change the Batch Size in Queries
The default and the maximum for query result batch size is 2,000 records. However, to optimize performance, the returned batch size can be lower than the max or what's set in the request, based on the size and complexity of records queried.
In REST API, use the batchSize field in the query options header to change the number of results returned in a single query. For more information, see Query in the REST API Developer Guide.
In SOAP API, change the batch size in the QueryOptions header before invoking the query() call. Salesforce Web Service Connector (WSC) clients can set the batch size by calling setQueryOptions() on the connection object. For more information, see query() in the SOAP API Developer Guide.
WSC (Java) Example to Set the Batch Size
The following Java WSC (Java) code example sets the batch size to 250records.
public void queryOptionsSample() {
connection.setQueryOptions(250);
}
C# (.NET) Example to Set the Batch Size
The following C# (.NET) code example sets the batch size to 250records.
private void queryOptionsSample()
{
binding.QueryOptionsValue = new QueryOptions();
binding.QueryOptionsValue.batchSize = 250;
binding.QueryOptionsValue.batchSizeSpecified = true;
}