You need to sign in to do that
Don't have an account?
Too many query rows 50001
H,
When i am trying to delete some records from object, i am getting this error 'Too many query rows 50001'. I have used the limit as 50000 in query. Still i am facing the same problem. How can i solve this issue.
I have used the limit in my query like as
for(store__C ss:[select id,Retail_Brand__c from store__C where Retail_Brand__c =:rid limit 50000])
setsid.add(ss.id);
For(StoreProduct_category__C spc:[select id,store__c,Product_category__C from StoreProduct_category__C where Store__c in : setsid limit 50000])
{
delspclist.add(spc);
system.debug(delspclist.size()+'del===');
}
if(delspclist.size()>0){
deletestoreproducts del=new deletestoreproducts(delspclist);
database.executebatch(del,1000);
I am getting the error at the line, which is bold in my code.
Thanks
As the first execution, where you are constructing the set may not contain more than 50000 record ids'.
What happens if you are removing the limit from the second for loop ?
Try the code block above, and see if it works.
Regards,
A
Hi Jo,
Set having only 174 ids. In both conditions i am facing the same issue. if for loop having 50000 limit or not. Please help me out.
Thanks
Hi,
The 50,000 records limit is for the overall instance. So if you are having 2 queries executed in one instance the sum of records returned by both the queries should not exceed 50,000.
Can you check if the records returned by both the queries is not more than 50,000.
Also try limiting the records to 10,000 and 40,000 in both the queries accordingly and check if the error still exists.
Let me know incase of any issue!