-
Database
Add query timeouts to database calls
Sets statement and request timeouts so slow or stuck queries fail fast instead of piling up behind a struggling database.
Free Prompt
Add timeouts to my database queries. Find where queries run and check whether any statement or execution timeout is set; most setups have none, which means a slow query runs forever.
Configure: a statement timeout at the database or driver level (something like 5-10 seconds for interactive web queries, longer only for known slow jobs like exports); error handling for timeout errors that returns a clean failure to the user instead of a hung request; and logging that records which query timed out so slow queries get found instead of silently retried by users refreshing.
Separate interactive queries from background jobs: exports, reports, and migrations legitimately need longer, so give them their own timeout instead of loosening the global one. Don't change query logic in this pass.
Deliver: the timeout configuration, per-context timeout values with reasoning, the error handling for timeouts, and verification: run an intentionally slow query and confirm it gets killed at the timeout instead of hanging.
What This Does / How This Helps
Makes slow queries fail fast. Without timeouts, one bad query holds a connection and a request thread until something else gives up, and enough of those pile up into a full outage. The pre-launch version of this bug is invisible: everything is fast with ten rows. Post-launch, a missing index or a big table turns one page into 30-second queries that stack up behind each other. Timeouts don't fix slow queries, they contain them, and the logging tells you exactly which queries to fix next.
Want to skip doing this by hand?
Fortivibe audits your app for all of the areas these prompts cover (and more).