INVISIBLE INDEX-11g [message #467041] |
Thu, 22 July 2010 02:16 |
akilabaskaran
Messages: 29 Registered: May 2007 Location: chennai
|
Junior Member |
|
|
Hi all,
I have been testing the invisible index with 11g
below is the script used
create table test_invisible (id number, descr varchar2(10));
create index idx_id_invisible on test_invisible(id) invisible;
insert into test_invisible select intproductid,nvclabel from product_tbl where rownum <=100
select * from test_invisible where id >104781
the explain plan is
SELECT STATEMENT, GOAL = ALL_ROWS
TABLE ACCESS FULL TEST_INVISIBLE
and i use the index hint as
select /*+ index (test_invisible idx_id_invisible) */ id from test_invisible where id = 104781;
then also the optimiser uses the full table scan
i then change the OPTIMIZER_USE_INVISIBLE_INDEXES parameter to true using
ALTER SESSION SET OPTIMIZER_USE_INVISIBLE_INDEXES = true;
even then the optimiser uses the full table scan
kindly clarify why i am not able to use the index even after the hint.
is there any way of including index for my sql ?
my version of oracle is Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
|
|
|
|
Re: INVISIBLE INDEX-11g [message #467051 is a reply to message #467047] |
Thu, 22 July 2010 02:38 |
akilabaskaran
Messages: 29 Registered: May 2007 Location: chennai
|
Junior Member |
|
|
hi,
i have inserted now 100000 rows and have gathered index statistics by dropping and recreating the index as below
insert into test_invisible select intproductid,nvclabel from play.product_tbl where rownum <=100000
create index idx_id_invisible on test_invisible(id) invisible compute statistics;
even now no luck
still using FTS
|
|
|
|
Re: INVISIBLE INDEX-11g [message #467074 is a reply to message #467061] |
Thu, 22 July 2010 03:59 |
akilabaskaran
Messages: 29 Registered: May 2007 Location: chennai
|
Junior Member |
|
|
Hi kindly find my session as below
SQL> create table test_invisible (id number, descr varchar2(128));
Table created
SQL> create index idx_id_invisible on test_invisible(id) invisible;
Index created
SQL> insert into test_invisible select object_id, object_name from dba_objects;
76602 rows inserted
SQL> commit;
Commit complete
SQL> ALTER SESSION SET OPTIMIZER_USE_INVISIBLE_INDEXES = true;
Session altered
SQL> exec dbms_stats.gather_table_stats (user,'TEST_INVISIBLE', cascade => true, estimate_percent => null);
PL/SQL procedure successfully completed
explain plan for select * from test_invisible where id = 104781;
PLAN_ID OPERATION OBJECT_NAME ROWS BYTES CPU_COST TIME
164 SELECT STATEMENT 1 28 15463 1
164 TABLE ACCESS TEST_INVISIBLE 1 28 15463 1
164 INDEX IDX_ID_INVISIBLE 1 8171 1
explain plan for select * from test_invisible where id > 104781;
PLAN_ID OPERATION OBJECT_NAME ROWS BYTES CPU_COST TIME
165 SELECT STATEMENT 1 28 21734 1
165 TABLE ACCESS TEST_INVISIBLE 1 28 21734 1
165 INDEX IDX_ID_INVISIBLE 1 14443 1
yeah it is using the index.. i can see it from the plan table.
Thanks a lot.
Since i do not have auto trace facility granted to my username, i used explain plan window in the plsql developer and it is still showing FTS.
But even then the execution plan seems to use the index.
I modified the OPTIMIZER_USE_INVISIBLE_INDEXES value to false and used the hint to see if the index is being used.
ALTER SESSION SET OPTIMIZER_USE_INVISIBLE_INDEXES = false;
explain plan for select /*+ index (test_invisible idx_id_invisible) */ id from test_invisible where id > 104781;
the explain plan is
PLAN_ID OPERATION OBJECT_NAME ROWS BYTES CPU_COST TIME
171 SELECT STATEMENT 1 5 17955333 1
171 TABLE ACCESS TEST_INVISIBLE 1 5 17955333 1
i saw some articles mentioning that when the OPTIMIZER_USE_INVISIBLE_INDEXES is set to false, then the index can be used by including the hint in the sql.
but in my case, the index is not used.
kindly provide suggestions for this scenario.
Thanks Micheal.
|
|
|
|
|
|
|
Re: INVISIBLE INDEX-11g [message #467140 is a reply to message #467137] |
Thu, 22 July 2010 05:27 |
akilabaskaran
Messages: 29 Registered: May 2007 Location: chennai
|
Junior Member |
|
|
Michel,
So there no ways of explicitly using an invisible index.
we can change the OPTIMIZER_USE_INVISIBLE_INDEXES parameter to TRUE to use the invisble index.
Thanks for the clarification.
|
|
|