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
Mahesh sfdc 5Mahesh sfdc 5 

Urgent : Can any one tell me how to resolve First error: [QUERY_TIMEOUT] Your query request was running for too long."?

Hi All,
Any on know how to resolve First error: [QUERY_TIMEOUT] Your query request was running for too long." ?

This the query I am using in my batch class start Method:

filterDate is Today date.

query = 'SELECT Id, Case__c  FROM Case_Action__c WHERE Case__r.ClosedDate >= ' + filterDate + ' OR Case__r.ClosedDate = NULL ORDER BY Case__r.Temp_Case_Action_Date__c';

If any one help will appriciate.

Thanks,
Mahesh

 
Amit Chaudhary 8Amit Chaudhary 8
It look like you are doing order by on large data base. Please try to remove order by from lookup field and use any other fields.
Please check below post to improve your query
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_VLSQ.htm

Let us know if this will help you
ManojjenaManojjena
Hi Mahesh ,

Can you remove the or condition and check once ,what I feel lot of records returning with closeddate with null value .
Check how many case records are there in your org .Then remove or condition and check ,Let us know if it helps !!
Thanks
Manoj
Mahesh sfdc 5Mahesh sfdc 5
Hi Manoj,

Batch job is getting only 3000 records for this query.

Thanks,
Mahesh