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
Mitchell SpanoMitchell Spano 

Odd SOQL Timeout

I am having an odd query timeout error and I don't know why. I am really confused as to why it is timing out because it is only selecting one record. It typically happens on the weekends (I don't know if that would make any difference). Here is the error message as well as the query.

User [dataintegration@ampf.com.aacprod].  SOSQL [Select LastModifiedDate From Event Where Activity_Type__c!='Email' AND Activity_Type__c!='Internal Activity' AND Event_Status__c='Appointment Held' AND IsDeleted=False ORDER BY LastModifiedDate DESC NULLS LAST LIMIT 1].  Fault code [sf:QUERY_TIMEOUT].  Reason [QUERY_TIMEOUT: Your query request was running for too long.].

Does anyone have any clues as to why this is happening?

 
Best Answer chosen by Mitchell Spano
James LoghryJames Loghry
I'd imagine it has to do with the selectivity of your SOQL query.  You have != filters in there, which are not selective and can decrease the performance of your SOQL query.  Have a look at the following cheatsheet, to see if there are ways you can improve your query: http://help.salesforce.com/help/pdfs/en/salesforce_query_search_optimization_developer_cheatsheet.pdf

All Answers

James LoghryJames Loghry
I'd imagine it has to do with the selectivity of your SOQL query.  You have != filters in there, which are not selective and can decrease the performance of your SOQL query.  Have a look at the following cheatsheet, to see if there are ways you can improve your query: http://help.salesforce.com/help/pdfs/en/salesforce_query_search_optimization_developer_cheatsheet.pdf
This was selected as the best answer
Mitchell SpanoMitchell Spano
Thanks! that worked out for me. I appreciate the help!