October 11, 2021

"Your query request was running for too long" exception in Salesforce

Your query request was running for too long
[sf: QUERY_TIMEOUT]. Reason [QUERY_TIMEOUT: Your query request was running for too long.]

If the query runs more than 2 mins(120 seconds), the query times out and throw the exception.

To avoid long execution times, non-selective SOQL queries may be terminated by the system.
https://help.salesforce.com/s/articleView?id=000325247&type=1

Maximum SOQL query run time before Salesforce cancels the transaction is 120 seconds(2 minutes). Check the following reference article.
https://developer.salesforce.com/docs/atlas.en-us.232.0.salesforce_app_limits_cheatsheet.meta/salesforce_app_limits_cheatsheet/salesforce_app_limits_platform_apexgov.htm

Use "SOQL_EXECUTE_BEGIN" in the Debug Logs. Find the start time and the time of the exception. If it is 120 seconds, then optimize the query.

Make SOQL selective to resolve this issue.
https://help.salesforce.com/s/articleView?id=000325257&type=1

No comments:

Post a Comment