[SalesForce] Total number of SOQL queries issued

In a SOQL query with parent-child relationship sub-queries, each
parent-child relationship counts as an additional query. These types
of queries have a limit of three times the number for top-level
queries.
Understanding Execution Governors and Limits

but when I run the query like

[select id, (select id from childs__r) from parent]

it is printed that: Number of SOQL queries: 1 out of 100

but based on the previous statement it should be 2

And what the statement means:

These types
of queries have a limit of three times the number for top-level
queries

Best Answer

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.

Related Topic