Salesforce Help Article
There is a help article suggested by Salesforce: https://help.salesforce.com/articleView?id=000339353&type=1&mode=1.
However, there are some good ways to use this.
PK Chunking – the one we used to use Bulk API
For example, let’s say you enable PK chunking for the following query on an Account table with 10,000,000 records.
SELECT Name FROM Account
Assuming a chunk size of 250,000 and a starting record ID of 001300000000000, the query is split into the following 40 queries. Each query is submitted as a separate batch.
SELECT Name FROM Account WHERE Id >= 001300000000000 AND Id < 00130000000132G SELECT Name FROM Account WHERE Id >= 00130000000132G AND Id < 00130000000264W SELECT Name FROM Account WHERE Id >= 00130000000264W AND Id < 00130000000396m SELECT Name FROM Account WHERE Id >= 00130000000euQ4 AND Id < 00130000000fxSK
Query using REST API – Inbuilt Query Locator
Call like this: curl https://yourInstance.salesforce.com/services/data/v50.0/query/?q=SELECT+name+from+Account -H “Authorization: Bearer token” would return not only 2000 records but also give link to get next 2000 records as below
“nextRecordsUrl” : “/services/data/v50.0/query/01gD0000002HU6KIAW-2000”