+ Start a Discussion
Daniel KDaniel K 

Number of query rows in Apex Class

Hi All,
         I know this is popular error message, but I need to understand something about this error.

         I have an Apex Controller used in a vf page.
         This class has 4 SOQL queries.
        1) select id,name from object1__c where id=:ids --> 5000 records
        2) select id,name from object2__c where id =:ids --> 8000 records
        3) select id,name,(select id,name from object3_1__c ) from object3__c where id =:ids --> 2000 records
        4) select id,name from object4__c where id =:ids --> 8000 records

      From Debug logs, I could see below when a button is clicked, which inturn calling the Apex Class:

       Number of query rows: 32000 out of 50000

       
I read from the document that for sub-queries/ queries with parent child relationship, the record count would be 3 or more times the actual records returned. But, can I know how exactly this "Number of query rows" be calculated ?

Thanks.
VamsiVamsi
Hi,

3rd query seems to be consuming more as it showing only parent record count as 2000. Just check the count of all child records returned in the 3rd query by adding them all to a list.