I am required to retrieve all the records (including archived and deleted records) from a Salesforce object. I understand that this can be achieved using queryAll(). However, I have an environment that has records in millions (>50M) and would prefer to query using Bulk API. I am thinking of submitting a faster approach to retrieve the data by:
- Querying the records (which do not contain the deleted and archived records) using Bulk API
- Individually query the rest.
Step 2 seems to be harder to specifically retrieve using Bulk API. If I'm not wrong, this can be achieved only by queryAll() and not by Bulk API. My understanding is that in order to retrieve the archived/deleted data is by the filter:
SELECT ID FROM OBJNAME [WHERE ISDELETED = TRUE OR ISARCHIVED = TRUE]
Is there a better way to query only the deleted and archived records taking the query load into considerations?