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
Diptiman Prusty 9Diptiman Prusty 9 

Number of query rows APEX resource warning

I am trying to find duplicate cases for a particular case . Below are the queries that are used in APEX :
Total number of records in Cases object is 200000 +

First this query :
SELECT PONumber__c,Tracking_Number__c,Customer_Full_Name__c,Id, CaseNumber FROM Case  WHERE Id =: strParentCaseId

Then below queries in a for loop( passing through the list of strFieldValues :
SELECT COUNT(Id) recCount FROM Case WHERE Id !=: strParentCaseId AND PONumber__c != NULL AND PONumber__c =: strFieldValue LIMIT 1000

SELECT COUNT(Id) recCount FROM Case WHERE Id !=: strParentCaseId AND Tracking_Number__c != NULL AND Tracking_Number__c =: strFieldValue LIMIT 1000

SELECT COUNT(Id) recCount FROM Case WHERE Id !=: strParentCaseId AND Customer_Full_Name__c != NULL AND Customer_Full_Name__c =: strFieldValue LIMIT 1000

But still I am getting the APEX resource warning for number of query rows. Not sure which query is the culprit here.
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Diptiman,

If you want to access more than 50000 records.You need to write a batch class.​ I hope it will be helpful.

Please mark it as Best Answer if the information is informative.

Best Regards
Rahul Kumar