3065
MySQLERRORNotablePerformanceHIGH confidence
Query execution was interrupted (maximum statement execution time exceeded)
Production Risk
High — long-running queries can consume significant server resources and block others.
What this means
The query exceeded the max_execution_time limit and was forcibly terminated by the server.
Why it happens
- 1The statement took longer than the value set in max_execution_time (in milliseconds).
- 2A per-query MAX_EXECUTION_TIME hint was set and exceeded.
- 3Large table scans, missing indexes, or heavy aggregations on big data sets.
How to reproduce
trigger — this will error
trigger — this will error
SELECT /*+ MAX_EXECUTION_TIME(100) */ * FROM large_table;
expected output
ERROR 3065 (HY000): Query execution was interrupted, maximum statement execution time exceeded
Fix 1
Add or improve indexes
Add or improve indexes
EXPLAIN SELECT * FROM large_table WHERE col = 'val'; ALTER TABLE large_table ADD INDEX idx_col (col);
Why this works
Index access avoids full table scans and speeds up queries.
Fix 2
Increase max_execution_time for the session
Increase max_execution_time for the session
SET SESSION max_execution_time = 5000;
Why this works
Raises the per-session limit in milliseconds.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3065 ER_QUERY_TIMEOUT2
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev