Common SQL Errors

MySQL Error 3126: ER_WARN_CONFLICTING_HINT - How to Fix and Prevent

Galaxy Team
August 8, 2025

MySQL raises ER_WARN_CONFLICTING_HINT (code 3126) when two or more optimizer hints in a statement contradict each other, causing one to be ignored.

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 3126 ER_WARN_CONFLICTING_HINT?

ER_WARN_CONFLICTING_HINT occurs when MySQL detects contradictory optimizer hints in a query, so it ignores the duplicate or conflicting hint. Remove the overlapping hints or rewrite the statement to use a single, clear hint to resolve the warning.

Error Highlights

Typical Error Message

ER_WARN_CONFLICTING_HINT

Error Type

Query Hint Warning

Language

MySQL

Symbol

ER_WARN_CONFLICTING_HINT was added in 5.7.7.

Error Code

3126

SQL State

HY000

Explanation

Table of Contents

What is MySQL error 3126 ER_WARN_CONFLICTING_HINT?

MySQL error 3126, ER_WARN_CONFLICTING_HINT, is a warning generated when the optimizer finds two or more hints in the same query that request incompatible execution strategies. MySQL proceeds with execution but drops the redundant hint.

This warning appears as Hint %s is ignored as conflicting/duplicated and was introduced in MySQL 5.7.7 to help developers detect ineffective or contradictory directives.

What Causes This Error?

Conflicting hints occur when you specify mutually exclusive options, such as both USE_INDEX and IGNORE_INDEX for the same table, or multiple JOIN_ORDER hints that contradict each other.

The error can also appear when identical hints are repeated, leading MySQL to treat later hints as duplicates and ignore them.

How to Fix ER_WARN_CONFLICTING_HINT

Remove redundant hints so only one directive remains per table or join. Confirm that the remaining hint matches your intended execution plan.

If you need multiple hints, chain them in a single list inside the same comment block to avoid duplication.

Common Scenarios and Solutions

During index tuning, developers often add USE_INDEX and later IGNORE_INDEX on the same table. Delete the less relevant directive.

When merging code, duplicate JOIN_HINT blocks may exist. Consolidate them into a single coherent hint set.

Best Practices to Avoid This Error

Audit all optimizer hints during code reviews, ensuring that each table has only one hint type per query.

Use descriptive comments and version-controlled SQL collections in Galaxy so teammates know which hint is the current source of truth.

Related Errors and Solutions

ER_WRONG_USAGE warns about incompatible GROUP BY functions. Resolve by aligning aggregate functions.

ER_PARSE_ERROR flags syntax mistakes. Fix by correcting malformed SQL.

Common Causes

Conflicting index hints

Specifying USE_INDEX and IGNORE_INDEX for the same table forces MySQL to ignore one hint.

Duplicate join order hints

Listing two JOIN_ORDER hints that reorder tables differently causes a clash.

Mixed join strategy hints

Combining NO_BNL and NO_MERGE hints in the same statement can be contradictory.

Copy-pasted legacy hints

Old hints left in a query after refactoring create duplication with new hints.

Related Errors

ER_PARSE_ERROR (1064)

Raised when SQL syntax is incorrect.

ER_WRONG_USAGE (1221)

Signals misuse of functions or clauses together.

ER_WARN_DEPRECATED_SYNTAX (1287)

Warns about deprecated SQL constructs.

ER_ILLEGAL_HA (1031)

Occurs when a storage engine does not support a requested feature.

FAQs

Does ER_WARN_CONFLICTING_HINT stop query execution?

No. It is a warning, so the query still runs but MySQL drops the conflicting hint.

Will removing all hints slow my query?

Not necessarily. Test performance with and without hints. Often the optimizer chooses the best plan automatically.

How can Galaxy help prevent hint conflicts?

Galaxy’s versioned Collections let teams endorse a single correct query, reducing duplicate hints and catching warnings during reviews.

Is this warning present in earlier MySQL versions?

No. ER_WARN_CONFLICTING_HINT was added in MySQL 5.7.7 and later.

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