MySQL error 3024: Maximum statement execution time exceeded
A SELECT ran longer than max_execution_time (or a MAX_EXECUTION_TIME hint) and the server stopped it.
- Error number
3024- Name
ER_QUERY_TIMEOUT- SQLSTATE
HY000- Category
- Transactions and locking
What it means
MySQL can cap how long a read-only SELECT may run, through the max_execution_time variable (in milliseconds; 0 means no limit) or a MAX_EXECUTION_TIME(n) optimizer hint. When the limit passes, the statement is interrupted with 3024. It doesn't apply to writes or to SELECT inside stored programs.
Common causes
- A slow query hitting a limit set for the session, account or server.
- A hosting provider or proxy that sets
max_execution_time.
How to fix it
-
Check the limit.
SELECT @@max_execution_time;
-
Speed the query up: look at its plan, add indexes, page through results.
EXPLAIN ANALYZE SELECT ...;
-
Raise the limit for one query when it really needs longer.
SELECT /*+ MAX_EXECUTION_TIME(60000) */ COUNT(*) FROM events;
Related errors
2013Lost connection to MySQL server during query57014PostgreSQL: canceling statement8645SQL Server: Timeout waiting for memory resources
More transactions and locking errors
1205Lock wait timeout exceeded1213Deadlock found when trying to get lock3572Lock couldn't be acquired with NOWAIT1206Locks exceed the lock table size1792Write in a READ ONLY transaction
The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.
Work on MySQL in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.