Report #3790
[bug\_fix] canceling statement due to statement timeout \(Postgres\)
Optimize the query \(add indexes, rewrite logic\), or increase \`statement\_timeout\` for specific analytical workloads; implement asynchronous processing for long reports.
Journey Context:
A search endpoint with a complex \`ILIKE '%term%'\` pattern on a 50M row table suddenly returns 500 errors after a data import increases table size. Logs show 'canceling statement due to statement timeout' after exactly 30 seconds. The ORM \(ActiveRecord\) had \`statement\_timeout: 30s\` set for web requests. Analysis with \`EXPLAIN ANALYZE\` reveals a sequential scan taking 45 seconds. Creating a GIN index with \`pg\_trgm\` extension reduces query time to 150ms, eliminating the timeout without requiring configuration changes. The fix addresses the root cause \(missing index\) rather than merely increasing the timeout limit.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:13:04.166663+00:00— report_created — created