How to Fix MySQL Error 3125 (ER_WARN_UNSUPPORTED_MAX_EXECUTION_TIME)
You trigger mysql error 3125 when you put a query execution time hint inside a statement that is not a top-level read query. To fix this warning, remove the hint from write queries, subqueries, or stored programs, and place it only on standalone read queries. Database teams use execution time hints to stop slow queries from locking up shared servers. Still, the database engine has strict rules about where these hints can run. When an app or engineer places the hint in the wrong spot, the server
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You trigger mysql error 3125 when you put a query execution time hint inside a statement that is not a top-level read query. To fix this warning, remove the hint from write queries, subqueries, or stored programs, and place it only on standalone read queries.
Database teams use execution time hints to stop slow queries from locking up shared servers. Still, the database engine has strict rules about where these hints can run. When an app or engineer places the hint in the wrong spot, the server returns sqlstate HY000 with symbol ER_WARN_UNSUPPORTED_MAX_EXECUTION_TIME. The official engine message states that the MAX_EXECUTION_TIME hint is supported by top-level standalone SELECT statements only.
Root causes of mysql error 3125 in the database engine
The MySQL optimizer reads execution time hints only on outer, read-only statements. If you attach the hint to an insert, update, or delete statement, the engine ignores the hint and logs mysql error 3125. The server prevents partial writes by blocking timeouts on data changes. Stopping a write halfway through can leave tables in a bad state or cause heavy rollback load.
You will also see this warning if you place the hint inside a subquery or a view definition. Even though a subquery reads data, it is not a top-level standalone statement. The query planner needs one clear time limit for the whole execution plan, not separate timers for inner query blocks.
Stored procedures, functions, triggers, and events also reject this hint. When a read query runs inside a stored routine, the engine treats the routine call as the top-level statement. Any time hint inside the routine body gets ignored and raises code 3125. Client tools and object-relational mappers can also cause this problem when they wrap user queries inside outer count queries or union blocks.
How to diagnose and fix the warning in production
Start by checking your database warning logs and query audit trail to find the exact statement. Look for any query that carries the execution time hint inside a nested block or a data write command. Check if an app framework adds the hint to every outgoing query by mistake.
To fix a nested read query, move the execution time hint from the inner subquery to the outer select keyword. This gives the optimizer a valid top-level timer for the whole read operation. If a reporting tool wraps your query in a view or derived table, apply the timeout at the outermost query layer instead.
Mean Time to Detect (MTTD) + MySQL Access Governance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
For write statements or stored routines, remove the hint from the SQL text. Do not grant broad server admin rights to developers just so they can change global timeout settings. Instead, configure query read timeouts in your app driver or session settings for that specific workload. You can also test ad-hoc queries in a staging database before running them in production. If sensitive fields like emails, phone numbers, card numbers, or national IDs appear in query results during testing, use data masking to rewrite matched fields in results while you tune query speed.
Preventing timeout hint errors across engineering teams
Many timeout warnings happen when engineers add hints by hand during a live outage. A developer might try to make a slow update safe by pasting a read timeout hint onto it. Because the engine ignores the hint on writes, the slow update still runs without a time limit.
Teach your team how the optimizer handles query hints so they do not rely on ignored timers. Set up code review checks to catch hints attached to write queries or stored routines before code ships. Using standard session limits for read users keeps your database fast and keeps your logs clean.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.
First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.
Frequently asked questions
Does mysql error 3125 stop my query from running?
No, code 3125 is a warning, not a hard failure. The database engine ignores the unsupported time hint and runs the rest of your statement as normal unless strict error modes turn warnings into errors.
Why does MySQL block execution time hints on update and delete queries?
MySQL only supports this hint on top-level standalone read queries. Stopping a write query mid-flight forces the storage engine to roll back changes, which can hurt server speed and lock rows for a long time.
Can I use the execution time hint inside a stored procedure?
No, the engine does not allow the hint on statements inside stored procedures, functions, triggers, or events. You must remove the hint from the routine body and manage timeouts at the session or app layer.
Related guides
In this post