System.LimitException: Too many query rows: 50001
There is a limit to the number of records that that can be retrieved by the SOQL query, which is 50000 records. The 50000 limit is an overall per-transaction limit and not a per-query limit. If you attempt to query the more than 50000 records, you will get an exception.
Sample Business Use Cases
- When running Category Maintenance, the following error occurs: Apttus_Config2:Too many query rows: 50001
- When trying to add more than 100 products from Catalog, CPQ displays a message: Apttus_Config2:Too many query rows: 50001
- When there are more than 400 lines added to the quote, the performance of CPQ is impacted.
Best Practices
- Use Batch Apex, in which the 50000 limit counts for each batch execution.
- These limits count for each Apex transaction. For Batch Apex, these limits are reset for each execution of a batch of records in the execute method.
- Limit the results by adding more criteria or using a LIMIT 50000 statement in SOQL.
In CPQ
- All constraint conditions or actions must have a narrow search.
- Avoid using Product field set.