You need to sign in to do that
Don't have an account?
Sunny_Slp
Inner SOQL query and governor limits
Hi Everyone,
I'm trying to retrieve Partial_Control_Group__c records connected via junction object CSAP_CGLP_Junction__c to CRD__c
here is my query:
pcgList=[SELECT Id,Name,CSAP_Control_ID__c,CSAP_Plan_ID__c FROM Partial_Control_Group__c WHERE Id IN (SELECT Partial_Control_Group__c FROM CSAP_CGLP_Junction__c WHERE CRD__c=:sourceCrdId) ORDER BY Name]; /*build string*/ for(Partial_Control_Group__c pcg:pcgList){ s=s+pcg.get('CSAP_Control_ID__c')+pcg.get('CSAP_Plan_ID__c')+','; }
is it safe (in terms of governor limits) to use inner query in this case? there are 2000-3000 records for each CRD__c and I'm worried about hitting any governor limits...would you call this safe way to do it or is there another even better way ?
Thank you,
SunnySlp
The docs state that each sub-query counts as an additional query for the purpose of governor limits. Its a perfectly reasonable way to pull back parents and their children as long as you don't return 50,000 rows and breach that governor limit.
All Answers
The docs state that each sub-query counts as an additional query for the purpose of governor limits. Its a perfectly reasonable way to pull back parents and their children as long as you don't return 50,000 rows and breach that governor limit.
Thank you :)
The answer provided by @bob seems incorrect. Subquery never counted as an additional query. You could check it by executing the following method in your org.
Limit.getQueries();