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
vijendahr kvijendahr k 

SOQL query size issue in Parent child query.

Hello All,

 I have SOQL Query as follows

list<account> acclist= new list<accout>[SELECT Id,(SELECT Id FROM Opportunities) FROM Account limit ]

Now account have 3 records each child have 3 records. now tell me some one the list of acclist size will be 3 or 9.

 I had scenario where i have query like [parent,(child)(child)(child)]  in this query parent getting 1500 or bit more records. even though i am getting error like  more then 50,000  in query.

Can some one please answer my query. - Thanks Advance.
hi vijendahr,

 In a SOQL query with parent-child relationship sub-queries, each parent-child relationship counts as an additional query.
to understand in details refer below link :

i hope it helps you.
 Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
vijendahr kvijendahr k
Plyush-I am kind of confusted now , but can you tell me what are the best ways to split parent child to query in larger data sets.

 i know you blog. its helped  some times, thanks for  sharing new things :)

you can check the acclist list size using the system.debug(acclist.size());
and you should look at using Batch Apex to achieve your goals.

You cannot retrieve more than 50,000 records your SOQL calls in a single context.

However, with  Batch Apex your logic will be processed in chunks of anywhere from 1 to 200 records in a batch.
You'd need to modify your business logic to take the batching into account if necessary.
here is the Execution Governors and Limits reference :

Hops it will helps you Let me know