// MySQL error reference

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
Error message
Query execution was interrupted, maximum statement execution time exceeded

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

  1. Check the limit.

    SELECT @@max_execution_time;
  2. Speed the query up: look at its plan, add indexes, page through results.

    EXPLAIN ANALYZE SELECT ...;
  3. Raise the limit for one query when it really needs longer.

    SELECT /*+ MAX_EXECUTION_TIME(60000) */ COUNT(*) FROM events;

Related errors

More transactions and locking errors

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.

// fewer errors, faster fixes

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.