function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chirag MehtaChirag Mehta 

Understanding parent-child relationship Execution Limits

Apex Governor limit document states "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."

 

1) Referring to "In a SOQL query with parent-child relationship sub-queries, each parent-child relationship counts as an additional query." If i execute following query, the no of SOQL executed needs to be Three. Yet debug log shows me 1 Query (and not 3). Am I missing anything?

List<Account> a =[Select Id, (Select Id from Contacts),(Select Id from Cases) from Account];


2) Can someone elaborate more on what does "These types of queries have a limit of three times the number for top-level queries." means?

S_LieS_Lie

the SOQL is working fine in apex explorer so it might due to SOQL result limitation .

Chirag MehtaChirag Mehta

Hi Lie,

Yes I am aware that the query is fine, the question here is on what does the Apex Governor Limit "In a SOQL query with parent-child relationship sub-queries, each parent-child relationship counts as an additional query" MEANS.

The question is around understanding Governor limit, it is not about any issue.

S_LieS_Lie

Hi,

 

If you give limit in the SOQL ( eg limit 10 ), is the error still coming ?

Chirag MehtaChirag Mehta

Lie,

 

As I said earlier too, I am not facing any error. The point of discussion is how does Salesforce count such queries against Governor Limit i.e., what is the number of Queries executed when you execute any Parent Child Query.  

Prajapati.LakhanPrajapati.Lakhan

Hi Chirag,

 

Did you figure it out? I am confused too, what document is trying to say by statement "In a SOQL query with parent-child relationship sub-queries, each parent-child relationship counts as an additional query."

 

Thanks,

Lakhan

Prajapati.LakhanPrajapati.Lakhan

Hi All,

 

I figured it out, nested queries have their own limit of 300 and they don't show up in debug log. Thanks...

 

Regards,

Lakhan