+ Start a Discussion
Sanket BhosleSanket Bhosle 

What will contribute to the Total number of records retrieved by SOQL queries?

Hi all,

I have the following query :

Select id, (Select Name , email from contacts where email != null), (Select name,stagename from Opportunities where stagename = 'Closed Won') from Account where id in (select accountid from contact where email!=null) and id in(select accountid from opportunity where stagename = 'Closed Won') 

I wish to know if the governor limit for fetched records includes only accounts, child contacts and child opportunities or will it include the All contacts and opportunities mentioned in the where clause as well.

Thanks.
Deepak Pandey 13Deepak Pandey 13
Hi Sanket,
    Governor limit only consider parent object.
List<Account> lstAcc = [Select id, (Select Name , email from contacts where email != null), (Select name,stagename from Opportunities where stagename = 'Closed Won') from Account];
v varaprasadv varaprasad
Hi Sanket,

If we run below query it will consider as 1 query.
But it will count all rows means paren and child.
Ex : 
An account having two contacts and one opportunity. So here rows count is 4.
 
List<Account> lstAcc = [Select id, (Select Name , email from contacts),
                            (Select name,stagename from Opportunities)
                            from Account where id = '0010I00001fW0cG'];

Governor Limits

Hope it helps you.

Thanks
Varaprasad