3

I wrote a query in the Developer Console, and when I ran it, at the top of the screen it shows "Query Results - Total Rows: 258". Below that, in the preview panel, it only shows 8 records.

I know that normally when the "Query Results - Total Rows" count is in the thousands, it won't display all the records in the preview, which is fine. However, I've never had it refuse to show more than a handful of records when the total is that much higher.

Any idea as to why I'm not seeing the remaining records?

SOQL Query:

SELECT Id, Name, CreatedDate, Createdby.Name, Old_Org_Id__c, 
     (SELECT Id FROM Orders), 
     (SELECT Id from Opportunities), 
     (SELECT Id From Contacts), 
     (SELECT Id from Tasks), 
     (SELECT Id from Events) 
FROM Account 
WHERE BillingStreet = null 
     AND BillingCity = null 
     AND BillingState = null 
     AND BillingPostalCode = null 
     AND ShippingStreet = null 
     AND ShippingCity = null 
     AND ShippingState = null 
     AND ShippingPostalCode = null 
     AND AP_Account__c = null 
     AND AR_Account__c = null 
     AND (NOT Name LIKE '%DADM%') 

Screenshot from Developer Console enter image description here

5
  • 4
    What was the query that you ran?
    – sfdcfox
    May 17, 2019 at 3:18
  • Also a screenshot of the result might be helpful as well.
    – Mr.Frodo
    May 17, 2019 at 5:39
  • 1
    To the 5 people who reported this as "off topic", there's a reason why I didn't include the query initially - this is a general question about how the Dev Console displays information. The answer is not specific to my query because I'm not asking for help "fixing" my query. I'm asking for an explanation of what types of issues can cause a disparity between the 2 counts because I can't find documentation on it. I'm expecting something like "check your read permissions" even though I'm an admin, or "deleted records" even though I'm not using ALL ROWS. I will update my post, but keep that in mind
    – KB145
    May 17, 2019 at 20:14
  • Oops my initial vote was a misclick. This question seems legitimate.
    – Adrian Larson
    May 17, 2019 at 20:57
  • Quick question: so in your org you have 258 accounts matching those criteria? Or only 8 of them? May 17, 2019 at 23:01

1 Answer 1

2

You have written a query that has many subqueries. That would appear to be to be the cause of the reason you are seeing the disparity in the count of total rows returned.

While you've returned 8 Account records in the console, the total rows of related Orders, Opportunities, Contacts, Tasks, and Events to those Accounts would be the cause of the additional 250 rows. Those rows cannot be displayed in the Console in the form they're queried. You'll need to extract that data using code to see it along with which records each is related to.

See Understanding Query Results in the SOQL and SOSL Documentation for additional information, including example code.

Also, from the documentation:

In a SOQL query with parent-child relationship subqueries, each parent-child relationship counts as an extra query. These types of queries have a limit of three times the number for top-level queries. The limit for subqueries corresponds to the value that Limits.getLimitAggregateQueries() returns. The row counts from these relationship queries contribute to the row counts of the overall code execution.

In essence, each of your subqueries amounts to a separate query which is part of why it can't be displayed in the console with your main query on Accounts.

3
  • If I'm understanding your response correctly, it sounds like the "Query Results - Total Rows" sum is the record count of results returned from the query + the record count of results from the subqueries, but then why in queries such as the following is the row count only 53 then (the # of orders), and not Order count + OrderItems count (which would be closer to 150)? The preview shows 53 rows and the Query Results - Total Rows is 53. SELECT Id, (SELECT Id from OrderItems) from Order WHERE CreatedDate >= TODAY
    – KB145
    May 20, 2019 at 21:08
  • I also went to run the same query just now, and the Query Results - Total Rows count as well as the number of records shown in the previews is completely different (and I'm fairly confident that has nothing to do with any changes anyone in my org made over the weekend). I'm almost wondering if this had something to do with the major Salesforce Permissions issue they were addressing on Friday that caused them to shut down org access...?
    – KB145
    May 20, 2019 at 21:11
  • If you did this as an admin, I would tend to doubt it has anything to do with the permissions issue (depends on your actual record perms). Regardless of how you did this, the child records cannot be displayed in the Dev Console when queried from Account. You'd need to run each sub-query separately for each account. Try running every sub-query on each account that was returned and you should find the total related records will match the record count you receive when you run the base query again.
    – crmprogdev
    May 21, 2019 at 15:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .