# SQLCODE +394: Optimization hints used

Source: https://wndsoftware.com/mainframe-errors/sqlcode-plus-394

### SQLCODE +394: Optimization hints used

SQLCODE +394 (SQLSTATE 01629) is a warning from Db2 for z/OS that all the user-specified optimization hints it found for a statement were used when it chose the access path. Nothing failed, and processing continues normally.


#### Other names for this code

Also written as `SQLCODE 394`, `SQLCODE=+394`, `SQLCODE = 394`, `sqlcode +394`, `db2 +394`, `sqlstate 01629`, `user specified optimization hints used`, `OPTHINT 394`.


### What it means

Normally the Db2 optimizer picks the access path for each statement on its own. An optimization hint tells it which path to use instead. Hints can come from rows in PLAN_TABLE that carry a name in the OPTHINT column, chosen with the OPTHINT bind option, or from statement-level hints stored with the BIND QUERY command from DSN_USERQUERY_TABLE.

When Db2 finds hints for a statement and every one of them is valid, it uses them and reports +394. You'll see it in BIND and REBIND output for static SQL, or in the SQLCA after PREPARE for dynamic SQL. It confirms that the hints were applied.

Its partner is +395 (SQLSTATE 01628), which means at least one hint was invalid and ignored. +395 carries a reason code that says what was wrong with the hint.

The subsystem parameter SUPPRESS_HINT_SQLCODE_DYN can turn off +394 and +395 for dynamic SQL, for shops that use hints heavily and don't want the warnings returned to applications.


### Common causes

- A package was bound or rebound with an OPTHINT name, and Db2 found matching, valid hint rows in PLAN_TABLE.
- A statement-level hint was created with BIND QUERY, and the statement matched it.
- A dynamic statement matched a stored hint when it was prepared.
- An application treats any non-zero SQLCODE after PREPARE as an error, so a harmless +394 shows up as a failure.


### How to find the problem

- Look at the BIND or REBIND output for the package, or the SQLCODE after PREPARE, to see which statement reported it.
- EXPLAIN the statement and compare the new PLAN_TABLE rows with the hint rows, to confirm the path Db2 chose is the one you intended.
- Check the hint rows in PLAN_TABLE for that OPTHINT value, or the rows in DSN_USERQUERY_TABLE for statement-level hints.
- If the application stopped on +394, check how it tests SQLCODE after PREPARE.


### How to fix it

- Usually nothing. Confirm that the hinted access path performs well and returns correct results.
- If the hint is no longer wanted, remove the hint rows or the stored query hint, then rebind without the OPTHINT option.
- Change application error handling so it treats positive SQLCODEs after PREPARE as warnings, not errors.
- To stop +394 and +395 being returned for dynamic SQL, ask the Db2 system programmer about SUPPRESS_HINT_SQLCODE_DYN.


### IBM documentation

[IBM Db2 for z/OS documentation](https://www.ibm.com/docs/en/db2-for-zos/13.0.0). Use the documentation for your installed release.

This link opens the relevant IBM reference library or lookup instructions. Match the complete code and your installed product release; it is not a code-specific review.

[Report a correction to WND Software](https://wndsoftware.com/contact#message).

Technical reviewer: [Albert Joseph](https://wndsoftware.com/authors/albert-joseph), WND Software.

Last reviewed 2026-10-18 by the WND Software team. Written in our own words. For the full reference, check IBM’s Db2 for z/OS documentation for your release.


### Related codes

[SQLCODE -805 Package not found in plan Read →](https://wndsoftware.com/mainframe-errors/sqlcode-805)
[SQLCODE -818 Timestamp mismatch between program and DBRM Read →](https://wndsoftware.com/mainframe-errors/sqlcode-818)
[SQLCODE -905 Resource limit exceeded Read →](https://wndsoftware.com/mainframe-errors/sqlcode-905)
[SQLCODE +445 Value has been truncated Read →](https://wndsoftware.com/mainframe-errors/sqlcode-plus-445)

### Questions


#### Is +394 an error?

No. It's a warning that tells you the hints you supplied were used. The statement or bind carries on normally.


#### What's the difference between +394 and +395?

+394 means every hint found was valid and used. +395 means at least one hint was invalid and ignored, with a reason code saying why.


#### Can I stop Db2 returning +394?

For dynamic SQL, the subsystem parameter SUPPRESS_HINT_SQLCODE_DYN suppresses +394 and +395. For static SQL it appears in bind output, where it does no harm.

[Db2 SQLCODEs](https://wndsoftware.com/mainframe-errors/db2-sqlcodes) · [SQLCODE +304](https://wndsoftware.com/mainframe-errors/sqlcode-plus-304) · [SQLCODE +445](https://wndsoftware.com/mainframe-errors/sqlcode-plus-445)

[← All error codes](https://wndsoftware.com/mainframe-errors/)
