As I come up to speed on Oracle (having been a DB2-guy for the last couple decades), I see a A LOT of existing code that uses optimizer-hints in its queries.
From what I've read on various Oracle-focused web-sites, several Oracle "experts" advise AGAINST putting optimizer-hints in prodcution code because:
- With every Oracle patch or upgrade, the hint will probably be wrong.
- With every DDL, the hint will probably be wrong.
One "expert" says:
The reason to be wary of hinting is that by embedding hints in your SQL, you are overriding the optimizer and saying that you know more than it does – not just now, but every time in the future that your SQL will be run, irrespective of any other changes that may happen to your database. The likely consequence of this is that your SQL will possibly run sub-optimally now and almost certainly in the future.
So, if optimizer-hints are commonly known to be "uswise", why are they so frequently used? ( ... at least in the code I've seen )
Thanks for your advice!