Yes, finally, really ignoring hints – but it’s a sort of bug, of course.
Thanks to Timur Akhmadeev for telling us about bug 8432870 (you’ll need an account on MOS for the link) in his reply to Charles Hooper’s recent post.
In the upgrade from 9i to 10g there was a change in the “hint parser”. If you put a valid SQL keyword inside the hint delimiters (the note says /*+ */ but doesn’t mention the –+ alternative for specifying a hint, thought it’s probably still true there) when the keyword is not a valid hint – for example the word NOLOGGING which I have seen people use as if it were a hint – then Oracle will ignore all the hints.
Earlier versions of Oracle simply noticed that you had embedded something that wasn’t a valid hint, but that didn’t stop the parser from reading the rest of the hints correctly.
If the invalid hint is not a valid SQL keyword then there are no nasty side effects.
This might explain why I ran into an odd problem a little while ago when I added a comment to my hint list and found that the hints stopped working. I can’t remember the exact details any more but I think my comment was something along the lines of: “Do not … because …”, and this broke the hints until I changed it to “Don’t … because …”.
[Further reading on "ignoring hints"]

Thanks for the highlight. Worth adding that, although it has a bug number, it has been deemed to be “Not a Bug”.
Comment by Gary — January 16, 2011 @ 10:42 pm UTC Jan 16,2011 |
Could it be that only the hints AFTER the SQL keyword get ignored? I made the following quick example inserting the word NOLOGGING to different places in the hint:
Comment by Todor Botev — January 17, 2011 @ 9:01 am UTC Jan 17,2011 |
Todor,
the MOS-Bug is indeed named “Bug 8432870: NOLOGGING HINT IN 10G CAUSES HINTS AFTER IT TO BE IGNORED” – and there is an example similar to the one you provide.
Comment by Martin Preiss — January 19, 2011 @ 8:38 am UTC Jan 19,2011 |
It’s getting difficult to avoid using SQL keywords. With 1,144 to choose from in 10.2.0.4 you could have a pretty good game of Scrabble with them.
“SQL Keyword Scrabble” would be a pretty good team game for a conference. “Blank”,A,B,E,N,M,Q … anyone?
Comment by David Aldridge — January 17, 2011 @ 11:18 am UTC Jan 17,2011 |
Jonathan,
in his comment to Charles Hooper’s post Kerry Osborne gives the advice to separate hints from other comments – and this sounds convincing to me. On the other side I remember that Randolf Geist recently explained that “there are cases/environments where comments are stripped prior to execution” (with the example of PL/SQL). Do think it’s a good idea to separate hints from other comments? Or do you think it is save to add comments inside a hint (after the hint-Keywords)?
Comment by Martin Preiss — January 19, 2011 @ 8:54 am UTC Jan 19,2011 |
Here is a little note about the hinting: http://valentinnikotin.com/2012/01/31/comments-in-hint/
Comment by Valentin Nikotin — January 31, 2012 @ 2:19 pm UTC Jan 31,2012 |