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.
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.
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.
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.
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.
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.
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.
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.
Specifying USE_INDEX and IGNORE_INDEX for the same table forces MySQL to ignore one hint.
Listing two JOIN_ORDER hints that reorder tables differently causes a clash.
Combining NO_BNL and NO_MERGE hints in the same statement can be contradictory.
Old hints left in a query after refactoring create duplication with new hints.
Raised when SQL syntax is incorrect.
Signals misuse of functions or clauses together.
Warns about deprecated SQL constructs.
Occurs when a storage engine does not support a requested feature.
No. It is a warning, so the query still runs but MySQL drops the conflicting hint.
Not necessarily. Test performance with and without hints. Often the optimizer chooses the best plan automatically.
Galaxy’s versioned Collections let teams endorse a single correct query, reducing duplicate hints and catching warnings during reviews.
No. ER_WARN_CONFLICTING_HINT was added in MySQL 5.7.7 and later.