http://www.perlmonks.org?node_id=174717


in reply to Where the advice to use DBI bind parameters can go wrong (long)

There's probably a way to give Oracle an optimizer hint that would take care of this. I've seen DBAs use optimizer hints to make Oracle use certain indexes before.
  • Comment on Re: Where the advice to use DBI bind parameters can go wrong (long)

Replies are listed 'Best First'.
Re: Re: Where the advice to use DBI bind parameters can go wrong (long)
by dws (Chancellor) on Jun 14, 2002 at 20:19 UTC
    There's probably a way to give Oracle an optimizer hint that would take care of this. I've seen DBAs use optimizer hints to make Oracle use certain indexes before.

    Not in this case. Hints influence how a query gets executed, but not in ways (as far as I know) that would result in the answer being wrong. Honoring a "trust me, you can use an index" hint would result in a bogus result set if the value bound for a LIKE clause had a leading wildcard.

    Hints are great when a query plan is joining tables in a reasonable, but suboptimal, sequence. Any way you join should give you the same result set.

      We ran into this problem with some of our code. When our DBA talked with Oracle Tech Support, they said to use an index hint. The Oracle tech said that an index would then be used, unless the parameter started with wildcard. At that time it would recompile the query to not use the index. Oracle would then keep both versions of the query cached and would use the appropriate one. The hints are just that, hints. If it doesn't work then Oracle ignores them.