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
Mitesh Saparia 8Mitesh Saparia 8 

how can I solve this ? System.LimitException: Too many query rows: 50001

System.LimitException: Too many query rows: 50001

 
Best Answer chosen by Mitesh Saparia 8
Ajay K DubediAjay K Dubedi
Hi Mitesh,

I hope you are doing well but make sure salesforce allow you to Total number of records retrieved by SOQL queries only 50,000
You can check Apex Governor Limits.

You can follow this link for know about Governor Limits:

https://developer.salesforce.com/docs/atlas.en-us.salesforce_app_limits_cheatsheet.meta/salesforce_app_limits_cheatsheet/salesforce_app_limits_platform_apexgov.htm

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks,
Ajay Dubedi

All Answers

Ajay K DubediAjay K Dubedi
Hi Mitesh,

I hope you are doing well but make sure salesforce allow you to Total number of records retrieved by SOQL queries only 50,000
You can check Apex Governor Limits.

You can follow this link for know about Governor Limits:

https://developer.salesforce.com/docs/atlas.en-us.salesforce_app_limits_cheatsheet.meta/salesforce_app_limits_cheatsheet/salesforce_app_limits_platform_apexgov.htm

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks,
Ajay Dubedi
This was selected as the best answer
Deepali KulshresthaDeepali Kulshrestha
Hi Mitesh,

This exception is coming because you cross the governor limits.
Salesforce has its limits of accessing data and performing DML operations and all. you have to take care of governor limits.
please go through the given links to know about the governor limits in salesforce and apex.
-https://developer.salesforce.com/docs/atlas.en-us.salesforce_app_limits_cheatsheet.meta/salesforce_app_limits_cheatsheet/salesforce_app_limits_platform_apexgov.htm
-https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm

if you want to do operations or manipulate as much of records you have to use batch apex.
for batch apex please go through the given links.
-https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
-https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch.htm     

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
Mitesh Saparia 8Mitesh Saparia 8
it will solve throw distnict query or not possible? or Batch Apex Class