Common SQL Errors

MySQL Error 3128: ER_UNRESOLVED_HINT_NAME - How to Fix and Prevent

Galaxy Team
August 8, 2025

MySQL cannot resolve the optimizer hint name specified in the /*+ */ comment of a statement.

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 3128 ER_UNRESOLVED_HINT_NAME?

ER_UNRESOLVED_HINT_NAME occurs when MySQL 5.7.7 or later cannot match the hint name provided in an optimizer hint comment with any valid hint for the clause being targeted. Correct the spelling, use a supported hint for your server version, or remove the invalid hint to resolve the error.

Error Highlights

Typical Error Message

ER_UNRESOLVED_HINT_NAME

Error Type

Query Optimizer Hint Error

Language

MySQL

Symbol

ER_UNRESOLVED_HINT_NAME was added in 5.7.7.

Error Code

3128

SQL State

HY000

Explanation

Table of Contents

What is MySQL error 3128 ER_UNRESOLVED_HINT_NAME?

Error 3128 appears when MySQL fails to map the name inside an optimizer hint comment to a supported hint. Starting in 5.7.7, MySQL introduced parser validation for hints and raises ER_UNRESOLVED_HINT_NAME if the name is misspelled, unsupported, or used in the wrong context.

The server stops parsing hints at the first unresolved name, skips the remaining hints, and continues executing the statement with default optimization rules. Although the query still runs, the intended tuning directive is ignored, so performance may differ from expectations.

What Causes This Error?

Misspelled hint names are the top reason: a typo like INDEXES instead of INDEX can trigger the error immediately. Version mismatch also matters - a hint introduced in MySQL 8.0 will not be recognized by 5.7.x and will raise ER_UNRESOLVED_HINT_NAME.

Using a clause-specific hint in the wrong place, such as JOIN_ORDER inside a SELECT list rather than the SELECT hint list, produces the same error. Finally, forgetting to qualify table aliases inside hints can leave MySQL unable to resolve the identifier.

How to Fix ER_UNRESOLVED_HINT_NAME

Start by checking the exact spelling of every hint in the /*+ */ block. Cross-reference with the MySQL manual for your server version to ensure the hint is valid and supported.

If the hint is new to a later release, remove it or upgrade MySQL. When table aliases are involved, prefix the hint with the correct alias, for example INDEX(t1 idx_user_id) instead of INDEX(idx_user_id).

Common Scenarios and Solutions

Developers migrating queries from MySQL 8.0 to 5.7 often leave in BKA or NO_ICP hints that 5.7 cannot parse. Removing or replacing them with equivalent optimizer switches resolves the error quickly.

Automated query generators may output empty hint slots such as MAX_EXECUTION_TIME() if no value is supplied. Adding the required argument or deleting the hint prevents ER_UNRESOLVED_HINT_NAME.

Best Practices to Avoid This Error

Validate hints in staging before deploying to production. Pair continuous-integration checks with the SELECT /*+ SET_VAR(optimizer_switch='derived_merge=off') */ 1 technique to make sure hints compile.

Use Galaxy’s schema-aware autocomplete, which lists only hints supported by the connected MySQL version. This minimizes typos and version drift.

Related Errors and Solutions

ER_UNSUPPORTED_HINT (3130) surfaces when the hint syntax is recognized but not allowed for the statement type. ER_WARN_UNSUPPORTED_HINT (3129) logs a warning rather than an error for non-critical mismatches. Both can be fixed by adjusting or deleting the offending hint.

Common Causes

Misspelled Hint Name

Typing NOICP instead of NO_ICP or INDEXES instead of INDEX leads MySQL to reject the name as unresolved.

Unsupported MySQL Version

Running a query written for 8.0 on 5.7.x introduces hints like BKA that the older server does not recognize.

Wrong Hint Context

Placing a JOIN-specific hint in a SELECT-level hint list (or vice versa) causes the optimizer to flag the name as unresolved for that clause.

Missing Table Alias

Hints referencing an index or table must match the alias used in the FROM clause. Omitting the alias breaks resolution.

Related Errors

ER_UNSUPPORTED_HINT (3130)

The hint name is known but not allowed in the statement context. Remove or move the hint.

ER_WARN_UNSUPPORTED_HINT (3129)

MySQL logs a warning instead of throwing an error when a non-critical hint is ignored.

ER_PARSE_ERROR (1064)

Generic syntax error that may appear if the hint comment itself is malformed.

FAQs

Can I ignore ER_UNRESOLVED_HINT_NAME and let the query run?

The query runs, but MySQL ignores the hint, so performance may differ from your expectations. It is safer to fix the hint.

Does upgrading to MySQL 8.0 fix this error automatically?

Upgrading may add support for newer hints, but any misspellings or context issues will still raise ER_UNRESOLVED_HINT_NAME.

How do I check which optimizer hints MySQL supports?

Consult the MySQL manual for your exact version, or run SHOW OPTIMIZER_HINTS in 8.0.29+ to list supported hints.

How does Galaxy help avoid hint errors?

Galaxy’s context-aware autocomplete shows only hints valid for the connected database version and flags typos in real time.

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