Common SQL Errors

MySQL Error 3125 ER_WARN_UNSUPPORTED_MAX_EXECUTION_TIME - How to Fix and Prevent

Galaxy Team
August 8, 2025

The MAX_EXECUTION_TIME optimizer hint was used on a statement type that does not support it, so MySQL returns warning 3125.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 3125 ER_WARN_UNSUPPORTED_MAX_EXECUTION_TIME?

MySQL error 3125 ER_WARN_UNSUPPORTED_MAX_EXECUTION_TIME occurs when the MAX_EXECUTION_TIME optimizer hint is applied to anything other than a top-level SELECT. Remove the hint or move it to the outermost SELECT to resolve the warning.

Error Highlights

Typical Error Message

ER_WARN_UNSUPPORTED_MAX_EXECUTION_TIME

Error Type

Optimizer Hint Warning

Language

MySQL

Symbol

standalone SELECT statements only The MAX_EXECUTION_TIME optimizer hint is supported only for SELECT statements. ER_WARN_UNSUPPORTED_MAX_EXECUTION_TIME was added in 5.7.7.

Error Code

3125

SQL State

HY000

Explanation

Table of Contents

What is MySQL error 3125 ER_WARN_UNSUPPORTED_MAX_EXECUTION_TIME?

Error 3125 signals that MySQL accepted your query but ignored the MAX_EXECUTION_TIME hint because it was not placed on a top-level SELECT. The server records a warning instead of stopping execution.

The hint was introduced in MySQL 5.7.7 and only affects SELECT statements. Using it on UPDATE, DELETE, INSERT, or on subqueries makes it unsupported and therefore triggers this warning.

What Causes This Error?

The primary cause is placing MAX_EXECUTION_TIME inside a subquery or on a non-SELECT statement. MySQL scans the query tree and validates hints only for the topmost SELECT.

Another trigger is older client code that adds the hint generically to every statement, regardless of type, resulting in warnings during data-modifying operations.

How to Fix ER_WARN_UNSUPPORTED_MAX_EXECUTION_TIME

Ensure the hint appears only on the outermost SELECT. If you need execution-time limits for other operations, remove the hint and rely on max_execution_time session variable instead.

You can also silence the warning by enabling sql_notes = 0 before running the query, though the preferred fix is correcting statement placement.

Common Scenarios and Solutions

In reporting dashboards, object-relational mappers may prepend the hint to subqueries. Rewrite the query so the main SELECT wraps the logic, then attach the hint to that wrapper.

For data migration scripts that run UPDATE ... SELECT, drop the hint entirely because updates are unsupported. Manage run-time with lock_wait_timeout or batch processing.

Best Practices to Avoid This Error

Centralize query generation and validate that hints are appended conditionally. Use code review or linting rules to block unsupported hints on DML statements.

Teams using Galaxy can create endorsed templates that show correct use of optimizer hints, letting developers reuse safe patterns without manual checks.

Related Errors and Solutions

ER_WARN_DEPRECATED_SYNTAX warns when you use outdated syntax; upgrade queries to modern forms. ER_PARSE_ERROR arises from malformed hints; verify brackets and syntax.

Common Causes

Hint on UPDATE/DELETE

MAX_EXECUTION_TIME added to data-modification statements that do not honor it.

Hint inside Subquery

Placed within an EXISTS, IN, or derived table rather than the top-level SELECT.

ORM or Generator Bug

Automatic code adds the hint indiscriminately to every statement type.

Legacy Migration Script

Older script predates MySQL 5.7.7 support rules and now triggers the warning.

Related Errors

ER_WARN_DEPRECATED_SYNTAX

Warns about outdated or removed features; occurs when using deprecated optimizer hints.

ER_PARSE_ERROR

Raised when hint syntax is malformed, such as missing parentheses.

ER_QUERY_INTERRUPTED

Occurs when max_execution_time kills a running query; check for long running queries.

FAQs

Does this warning stop my query?

No. MySQL runs the statement but ignores the unsupported hint.

Can I apply MAX_EXECUTION_TIME to UPDATE statements?

No. The hint is valid only for top-level SELECT. Use other timeout controls for DML.

How do I suppress the warning in logs?

Set sql_notes = 0 for the session, but correct placement is the recommended fix.

Is there a performance impact when the hint is ignored?

None, aside from minimal overhead parsing the unused hint.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo