Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: oracle can ignore hints
Comments embedded - catching up on 400 messages after 2 days away :(
> -----Original Message-----
> From: Jared.Still_at_radisys.com
> Sent: 10 March 2004 13:22
> To: Jared.Still_at_radisys.com; oracle-l_at_freelists.org
> Subject: Re: oracle can ignore hints
>
>
> Correct, so did Oracle 'ignore' the hint?
>
> I guess the point is this: does Oracle ignore your hints,
> or are they merely unusable?
I don't think that the experiment goes quite far enough.
I have repeated it with the following modification
Run the statement without the hint and c1 is null Run the statement with the hint and c1 is null.
Next
Run the statement without the hint and c1 is not null Run the statement with the hint and c1 is not null.
I.E. First see what oracle does on its own, then see what adding the hint does.
Output each of these to a separate 10053 trace file and compare.
In the null case Oracle *never* considers the index (as you should expect). In the not null case Oracle considers the index and rejects it without the hint in favour of the FTS, with the hint it only considers the index as an access path into t.
In other words I think this demonstrates quite well that hints (at least access path hints) don't ADD new access paths for consideration, but restrict the available access paths. Thus hinting an index that cannot be used* and so will never be considered is not (IMO) a case of "ignoring" the hint, but a case of supplying an invalid hint (just as if I'd supplied select /*+ index (idx t) */ to the query). In general I find this way of thinking about hints (as restricting the available choices for the optimizer) as quite helpful. It enables you when the CBO is 'ignoring' your hint to ask questions like - is the access path that I want actually available, have I restricted the optimizer's choices enough - as well as giving a hint (sorry for the pun) as to why bright people often look down on hints or treat them as a quick fix/ workaround. If you view every hint you give as handicapping Oracle in some way you tend to avoid sprinkling them liberally thorughout your code.
> You could also try this with a bitmapped index.
>
> Jared
And actually there is a prediction that can be made from the above for this case. Bitmapped indexes index nulls, therefore the bitmapped index will be available to the optimizer. Thus I predict that the bitmapped index will be *considered* without the hint (i.e it will show in a 10053 trace), and will be *chosen* with the hint.
Niall Litchfield
Oracle DBA
Audit Commission
+44 117 975 7805
-- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html -----------------------------------------------------------------Received on Fri Mar 12 2004 - 05:05:00 CST