Skip to main content
I'm getting the VF error message Too many query rows: 50001 and not sure how to fix it.  I'm looking at the VF page and not sure where to begin. 
1 respuesta
  1. 18 oct 2023, 08:01
    Hi Anna,

    The "Too many query rows: 50001" error in Salesforce occurs when your Visualforce page is attempting to retrieve or query more than 50,000 records from the database in a single operation. Salesforce imposes this limit to ensure efficient and optimized performance.

    To fix this issue, you should first review your Visualforce page's Apex controller or extension code to identify the specific query that is triggering the error.

    You can optimize your query by either refining the selection criteria to fetch fewer records or by implementing pagination to display data in smaller, manageable portions.

    Another approach is to use aggregate queries((e.g., using GROUP BY and SUM, COUNT, etc), which allow you to summarize data rather than fetching individual records.

    The below links will give an idea of the approaches you can follow:

    https://www.levelupsalesforce.com/too-many-query-rows-50001-in-salesforce 

    https://webnersolutions1.medium.com/system- limitexception-too-many-query-rows-50001-error-in-salesforce-8559b7f33e36 

    https://developer.salesforce.com/forums/?id=906F0000000925uIAA 

    https://developer.salesforce.com/forums/?id=906F00000008z3SIAQ 

    http://salesforce.stackexchange.com/questions/40916/too-many-query-rows-50001 

    If this information helps, please mark the answer as best. Thank you
0/9000