Issue
When running an Insights query, the query doesn't complete and an error message displays: "Canceling statement due to statement timeout"
Environment
Insights application
Cause
The query timed out.
Queries time out after one minute. If the query takes too long to compile, the error displays. The warehouse itself doesn't experience timeouts and we can't increase the limit.
Solution
We recommend optimizing your queries to prevent timeouts by prioritizing:
- Selecting only necessary columns
- Filtering early
- Setting a row limit
- Splitting queries
Avoid the following:
- FULL OUTER JOINs
- Expensive operators
If your query is optimized and still timing out, consider runningEXPLAIN
or EXPLAIN ANALYZE
operators on your query in the warehouse to identify bottlenecks.