In this post I would like to remove some misinformation about the utilization of hints with invisible indexes.
Let’s start by providing you what two sources say about that topic:
- Oracle Database 11g: New Features for DBAs and Developers (by Sam R. Alapati and Charles Kim, page 132)
“If you want the optimizer to take the invisible index into account, you must use the index hint, as shown in the following example:“
- Oracle Database 11g: The Top New Features for DBAs and Developers – Schema Management (by Arup Nanda)
“To make the optimizer use the index again, you have to explicitly name the index in a hint:”
Both sources point out that a hint can be used to compel the query optimizer to use an invisible index. Both also provide an example (not shown here). But, what is more important, both are wrong! In other words, a hint cannot be used to compel the query optimizer to use an invisible index.
What’s going on?!?
The problem is that this specific information used to be correct for the beta release of Oracle Database 11g. But that behavior was a bug, not a feature! Therefore, once the bug was fixed, this piece of information was no longer valid.
This is what happens when authors use beta releases for doing their tests…
Good remark, thank you. I didn’t know that this was a bug.
You are right, Chris. And I apologize for not responding to it earlier.
I was referred to this literally hours ago. Sometimes things change albeit
in small amounts between beta and production. Those articles were reviewed
by Oracle PM and they were supposed to have caught that. Well…. Anyway,
that’s not an excuse; but just a background.
In 11gR2, the series will be written with production code alone.
I sympathize with that… I know that editors want to have books (in your case, articles) as soon as the production release is available and, therefore, authors are pushed to work with beta releases. Hence, there are good chances that something like that happens.
I originally wrote this post because I heard that specific “myth” too many times! I though it was good to stop it. Or, at least, to try…
It’s good to know that for 11gR2 it will be different.
An update on invisible indexes and hints.
Oracle introduced the USE_INVISIBLE_INDEXES hint in 18.104.22.168, so provided your patched up it works correctly.
e.g. select /*+ USE_INVISIBLE_INDEXES */ * from your_table;
In fact they added quite a few new hints, see the V$SQL_HINT view for details.
Thank you very much for your comment. It points out an important thing…
To make things clear, in my post I was speaking about hints like INDEX and not the new hint USE_INVISIBLE_INDEXES. Let me give an example to make the point cristal clear to everyone ;-)
Thanks for good information. I created invisible index and forced query to use invisible index by using hint /*+ INDEX (schema.table schema.index) */ and tried with
another hint /*+ INDEX(table column) */ ; but all were using full table scan. After reading your article , used /*+ use_invisible_indexes */ and query started using that invisible index. Thanks again for your post.