Skip to main content
1 of 2
Macca
  • 8.3k
  • 1
  • 14
  • 22

The reason for your timeout error is you are running an expensive query that is timing out after 30 minutes. Salesforce has a useful page on optimisation of query activities. Many of the points I think you'll find useful in tuning the query above, most notably the use of intermediary/staging tables and joining on Primary Key fields. Also consider the need for expensive operations like DISTINCT and limiting result sets by using INNER, rather than OUTER joins.

Macca
  • 8.3k
  • 1
  • 14
  • 22