If you look at a Test Runner, you'll see different types of SOQL query reports, not just lines returned. I always see something that looks like this:
07:31:09.985|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 22 out of 100
Number of query rows: 76 out of 50000
07:31:09.985|LIMIT_USAGE_FOR_NS|mea|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
07:31:09.985|LIMIT_USAGE_FOR_NS|rh2|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
07:31:09.985|LIMIT_USAGE_FOR_NS|rhx|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
I have similar "related" subqueries and always see them reported as "Aggregations" not as parent-child queries as in the example below:
07:31:31.501 (45501966062)|SOQL_EXECUTE_BEGIN|[50]|Aggregations:3|select Id,
Ambassador_Rate__c, Additional_Paid_Time__c, EventID__c, RecordTypeId, RecordType.Name,
Owner.Id, Program_PO__c, SWS_Recomended_CE__r.Id, Automation_Errors__c, (select Id,
ActivityDateTime, Actual_Hours__c, WhoID, WhatId, OwnerID, RecordTypeId from Events),
(select Id, Opportunity__c from R00N40000001pm1JEAQ), (select Id, PromoEvent__c from
Recap_Forms_New__r) from Opportunity where (Id = :tmpVar1 and
(Opportunity.RecordType.DeveloperName = 'Setup_PromoEvent' or
Opportunity.RecordType.DeveloperName = 'Approved_PromoEvent'))
In many cases, something may be a "related" to another object, making it act as "child". I suspect the documentation is referring to a parent-child relationship where one is the Master and the other the Detail; not the situation where one object is the related object of another and thus behaves as a child but is not the child in a Master-Detail relationship.
Edit
The point I'm trying to make is that many related relationships can be unclear and it appears to me that SF is reporting them all as Aggregations
regardless of whether they're the direct child of a parent or simply on a related object. In the example above, Events
is obviously a related object, but not a direct child of Opportunity
. The same applies to Recap_Forms_New__r
. However, Opportunity
is the parent of R00N40000001pm1JEAQ
, yet all 3 are shown as Aggregations
. When I study what's reported as the log progresses, only the query rows increase because of the Aggregations
, not the number of SOQL queries.
Best Answer
Let's take the following SOQL:
In the above query there are total 3 subqueries + 1 parent query. So, there are 4 queries. But, Salesforce doesn't count subqueries against governor limit of 100 SOQLs. It counts only root query which means only 1 SOQL query would be consumed.
Subqueries are counted separately as
AggregateQueries
. You can check those withLimits.getAggregateQueries()
andLimits.getLimitAggregateQueries()
. You cannot have more than 300 aggregations in a single transaction. This is stated just below the sentence you quoted:So your count would be: