[SalesForce] Timeout for soql in sandbox

I am trying to run a few queries on the Event object.But the queries time out.

Querying the same in Full copy sandbox seems to be okay. But the time out happens in Production only. What could be the possible reasons? I believe, because of the large number of records, the time out is happening. How to look into it?

ERROR: QUERY_TIMEOUT: Your query request was running for too long.

Thanks.

Best Answer

Try running the query using the new query resource feedback parameter in both environments. There may be a difference in the query plan being used based on the volume of data and available indexes.

See Developing Selective Force.com Queries through the Query Resource Feedback Parameter Pilot

There should be an option to access this in the Developer Console with a Summer 14 Org. That won't help you at the moment with production.

Depending on your query, you may need to look at:

  • the types of joins being performed.
  • the where clause operators
  • the number of rows your query will be returning.

SOQL Query Execution Plan

Related Topic