Search code examples
salesforcesoql

Salesforce REST SOQL Returning Fewer Results Than Expected


I'm extracting data from a Salesforce REST endpoint with the following set of queries:

SELECT COUNT(Id) FROM Table1__c WHERE CreatedDate < 2017-10-18T16:16:03Z

This returns a result of: 216

SELECT Id FROM Table1__c WHERE CreatedDate < 2017-10-18T16:16:03Z ORDER BY CreatedDate ASC LIMIT 100 OFFSET 0

This returns the desired 100 results which I format as follows for the next query:

'result1', 'result2',...,'result100'

This query however is only returning 87 of the desired 100 records:

SELECT 
Id, CreatedDate, A whole lotta fields,
(SELECT Name, more fields FROM Table2__r),
(SELECT Name, Even more fields FROM Table3__r),
(SELECT Name, Yeah, more fields FROM Table4__r),
(SELECT Name, You guessed it! more fields FROM Table5__r),
(SELECT Name, finally, the last fields FROM Table6__r) 
FROM Table1__c WHERE Id IN (previous formatted result)

So my desire is for the query (ignoring the where-clause for a moment) to perform a left-outer join on Table1__c with the other tables and limit the results to only the Ids from the previous query. However, the where-clause seems to be forcing it into a left-inner join between Table1__c and the other tales? I'm not entirely sure. I'm querying against the Salesforce v39 REST interface.


Solution

  • nextRecordsUrl is getting populated due to the size of the response and needs to be followed.