What does this statement from the Execution Governors and Limits document mean?

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 row counts from these relationship queries contribute to the row counts of the overall code execution.

I tried:

List<Trail__c> records = [select Id,(select Id,type,Industry from Accounts__r) from trail__c]

but it shows only one query fired in Limit.getQueries().

1 Answer 1


A parent-child subquery is counted as an "Aggregate" query, which, despite the name, has nothing to do with SOQL Aggregate Functions.

The wording in the documentation is...not the clearest here. In a single transaction, you can have up to 300 parent-child subqueries. Each row returned by a parent-child subquery does count towards the 50,000 query row governor limit.

A subquery doesn't show up in Limit.getQueries(); as you've seen. Instead, you need to use Limits.getAggregateQueries();


You must log in to answer this question.

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