Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Re: Index usage

Re: Re: Index usage

From: bhabani s pradhan <bhabaniindia_at_rediffmail.com>
Date: Thu, 25 Dec 2003 03:59:25 -0800
Message-ID: <F001.005DB145.20031225035925@fatcity.com>


Content-type: text/html;
 charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

<P>=0A<BR>=0AHi,<BR>=0A<BR>=0ANice example and it should behave similarly i= n my case also. I have to research more..<BR>=0A<BR>=0A<BR>=0ARegards,<BR>=
=0AB S Pradhan<BR>=0A<BR>=0A-------------------<BR>=0AOn Wed, 24 Dec 2003 z=

hu chao wrote :<BR>=0A&gt;Hi,<BR>=0A&gt;&nbsp; &nbsp;  It cound be possible=
 that without Hint, oracle will choose FTS for second SQL, because with col=
3 clause, if using index, oracle will have to do a range scan on index ind1=
 and than table access by rowid.<BR>=0A&gt;&nbsp; &nbsp;  If CBO thinks tha=
t col1=3D'val1' will get a lot of rows then doing FTS may be cheaper.But wi=
th hint, oracle should be able to pick that index.<BR>=0A&gt;<BR>=0A&gt;<BR=
>=0A&gt;Sample:<BR>=0A&gt;00:48:18 system_at_CAT9&gt;&nbsp; create table test =
as select * from dba_tables;<BR>=0A&gt;<BR>=0A&gt;Table created.<BR>=0A&gt;=
00:48:45 system_at_CAT9&gt; create index ind1 on test(owner,table_name) comput=
e statistics;<BR>=0A&gt;<BR>=0A&gt;Index created.<BR>=0A&gt;00:49:39 system=
@CAT9&gt; select 'x' from test where owner=3D'PUBLIC';<BR>=0A&gt;<BR>=0A&gt=
;no rows selected<BR>=0A&gt;<BR>=0A&gt;Elapsed: 00:00:00.03<BR>=0A&gt;<BR>=
=0A&gt;Execution Plan<BR>=0A&gt;-------------------------------------------=
---------------<BR>=0A&gt;&nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; SELECT STATEM=
ENT Optimizer=3DALL_ROWS (Cost=3D2 Card=3D5 Bytes=3D15)<BR>=0A&gt;&nbsp; &n=
bsp; 1&nbsp; &nbsp; 0&nbsp;  INDEX (FAST FULL SCAN) OF 'IND1' (NON-UNIQUE) =
(Cost=3D2 Card<BR>=0A&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  =3D5 Bytes=3D1=
5)<BR>=0A&gt;00:50:00 system_at_CAT9&gt; select 'x' from test where owner=3D'P=
UBLIC' and tablespace_name=3D'SYSTEM';<BR>=0A&gt;<BR>=0A&gt;no rows selecte=
d<BR>=0A&gt;<BR>=0A&gt;Elapsed: 00:00:00.00<BR>=0A&gt;<BR>=0A&gt;Execution =
Plan<BR>=0A&gt;----------------------------------------------------------<B=
R>=0A&gt;&nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; SELECT STATEMENT Optimizer=3DA=
LL_ROWS (Cost=3D4 Card=3D1 Bytes=3D20)<BR>=0A&gt;&nbsp; &nbsp; 1&nbsp; &nbs=
p; 0&nbsp;  TABLE ACCESS (FULL) OF 'TEST' (Cost=3D4 Card=3D1 Bytes=3D20)<BR=
>=0A&gt;<BR>=0A&gt;00:51:14 system_at_CAT9&gt; select /*+index(test ind1)*/ 'x=
' from test where owner=3D'PUBLIC' and tablespace_name=3D'SYSTEM';<BR>=0A&g=
t;<BR>=0A&gt;no rows selected<BR>=0A&gt;<BR>=0A&gt;Elapsed: 00:00:00.01<BR>=

=0A&gt;<BR>=0A&gt;Execution Plan<BR>=0A&gt;--------------------------------=
--------------------------<BR>=0A&gt;&nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; SE= LECT STATEMENT Optimizer=3DALL_ROWS (Cost=3D5 Card=3D1 Bytes=3D20)<BR>=0A&g= t;&nbsp; &nbsp; 1&nbsp; &nbsp; 0&nbsp; TABLE ACCESS (BY INDEX ROWID) OF 'T= EST' (Cost=3D5 Card=3D1 Byt&nbsp; &nbsp; &nbsp; es=3D20)<BR>=0A&gt;&nbsp; = &nbsp; 2&nbsp; &nbsp; 1&nbsp; &nbsp; INDEX (FULL SCAN) OF 'IND1' (NON-UNIQ= UE) (Cost=3D3 Card=3D5)<BR>=0A&gt;<BR>=0A&gt;----- Original Message -----<B= R>=0A&gt;To: Multiple recipients of list ORACLE-L<BR>=0A&gt;Sent: Wednesday= , December 24, 2003 9:59 PM<BR>=0A&gt;<BR>=0A&gt;<BR>=0A&gt;<BR>=0A&gt;Hi A= ll,<BR>=0A&gt;<BR>=0A&gt;Merry Christmas to all.<BR>=0A&gt;<BR>=0A&gt;I hav= e this interesting problem..<BR>=0A&gt;<BR>=0A&gt;For this query index ind1= on (c1,c2) columns is getting used.<BR>=0A&gt;SELECT 'x'<BR>=0A&gt; FROM t= ab ta<BR>=0A&gt;WHERE ta.c1=3D'val1';<BR>=0A&gt;(gives index ind1 range sca= n)<BR>=0A&gt;<BR>=0A&gt;But for<BR>=0A&gt;<BR>=0A&gt;SELECT 'x'<BR>=0A&gt; = FROM tab ta<BR>=0A&gt;WHERE ta.c1=3D'val1'<BR>=0A&gt;AND ta.c3 =3D 'val2';<= BR>=0A&gt;(gives FTS)<BR>=0A&gt;index ind1 is not being used. c3 is a nonin= dexed column.<BR>=0A&gt;<BR>=0A&gt;I have already tried index(ta ind1) , RU= LE hints.<BR>=0A&gt;<BR>=0A&gt;The table and the index are analyzed.<BR>=0A= &gt;<BR>=0A&gt;<BR>=0A&gt;<BR>=0A&gt;What cud be the reason for that?<BR>=

=0A&gt;<BR>=0A&gt;<BR>=0A&gt;<BR>=0A&gt;Regards,<BR>=0A&gt;B S Pradhan<BR>=
=0A&gt;<BR>=0A&gt;<BR>=0A&gt;<BR>=0A&gt;<BR>=0A&gt;--<BR>=0A&gt;Please see =
the official ORACLE-L FAQ: http://www.orafaq.net<BR>=0A&gt;--<BR>=0A&gt;Aut= hor: zhu chao<BR>=0A&gt;&nbsp; INET: chao_ping_at_vip.163.com<BR>=0A&gt;<BR>=
=0A&gt;Fat City Network Services&nbsp; &nbsp; -- 858-538-5051 http://www.fa=
tcity.com<BR>=0A&gt;San Diego, California&nbsp; &nbsp; &nbsp; &nbsp; -- Mai=
ling list and web hosting services<BR>=0A&gt;------------------------------=
---------------------------------------<BR>=0A&gt;To REMOVE yourself from t=
his mailing list, send an E-Mail message<BR>=0A&gt;to: ListGuru_at_fatcity.com=
 (note EXACT spelling of 'ListGuru') and in<BR>=0A&gt;the message BODY, inc=
lude a line containing: UNSUB ORACLE-L<BR>=0A&gt;(or the name of mailing li=
st you want to be removed from).&nbsp; You may<BR>=0A&gt;also send the HELP=
 command for other information (like subscribing).<BR>=0A=0A</P>=0A<br><br>=

=0A<A target=3D"_blank" HREF=3D"http://clients.rediff.com/signature/track_s=
ig.asp"><IMG SRC=3D"http://ads.rediff.com/RealMedia/ads/adstream_nx.cgi/www= .rediffmail.com/inbox.htm_at_Bottom" BORDER=3D0 VSPACE=3D0 HSPACE=3D0 HEIGHT=
=3D74 WIDTH=3D496></a>=0A

--Next_1072353564---0-203.199.83.28-12769 Content-type: text/plain;
 charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable Content-Disposition: inline

=0AHi,=0A=0ANice example and it should behave similarly in my case also. I =

have to research more..=0A=0A=0ARegards,=0AB S Pradhan=0A=0A---------------=
----=0AOn Wed, 24 Dec 2003 zhu chao wrote :=0A>Hi,=0A>     It cound be poss=
ible that without Hint, oracle will choose FTS for second SQL, because with=
 col3 clause, if using index, oracle will have to do a range scan on index =
ind1 and than table access by rowid.=0A>     If CBO thinks that col1=3D'val=
1' will get a lot of rows then doing FTS may be cheaper.But with hint, orac=
le should be able to pick that index.=0A>=0A>=0A>Sample:=0A>00:48:18 system=
@CAT9>  create table test as select * from dba_tables;=0A>=0A>Table created=
.=0A>00:48:45 system_at_CAT9> create index ind1 on test(owner,table_name) comp=
ute statistics;=0A>=0A>Index created.=0A>00:49:39 system_at_CAT9> select 'x' f=
rom test where owner=3D'PUBLIC';=0A>=0A>no rows selected=0A>=0A>Elapsed: 00=
:00:00.03=0A>=0A>Execution Plan=0A>----------------------------------------=
------------------=0A>    0      SELECT STATEMENT Optimizer=3DALL_ROWS (Cos=
t=3D2 Card=3D5 Bytes=3D15)=0A>    1    0   INDEX (FAST FULL SCAN) OF 'IND1'=
 (NON-UNIQUE) (Cost=3D2 Card=0A>           =3D5 Bytes=3D15)=0A>00:50:00 sys=
tem_at_CAT9> select 'x' from test where owner=3D'PUBLIC' and tablespace_name=
=3D'SYSTEM';=0A>=0A>no rows selected=0A>=0A>Elapsed: 00:00:00.00=0A>=0A>Exe=
cution Plan=0A>----------------------------------------------------------=

=0A> 0 SELECT STATEMENT Optimizer=3DALL_ROWS (Cost=3D4 Card=3D1 Byt=
es=3D20)=0A> 1 0 TABLE ACCESS (FULL) OF 'TEST' (Cost=3D4 Card=3D1 B= ytes=3D20)=0A>=0A>00:51:14 system_at_CAT9> select /*+index(test ind1)*/ 'x' fr= om test where owner=3D'PUBLIC' and tablespace_name=3D'SYSTEM';=0A>=0A>no ro= ws selected=0A>=0A>Elapsed: 00:00:00.01=0A>=0A>Execution Plan=0A>----------= ------------------------------------------------=0A> 0 SELECT STATE= MENT Optimizer=3DALL_ROWS (Cost=3D5 Card=3D1 Bytes=3D20)=0A> 1 0 TA= BLE ACCESS (BY INDEX ROWID) OF 'TEST' (Cost=3D5 Card=3D1 Byt es=3D20)=
=0A> 2 1 INDEX (FULL SCAN) OF 'IND1' (NON-UNIQUE) (Cost=3D3 Card=
=3D5)=0A>=0A>----- Original Message -----=0A>To: Multiple recipients of lis=
t ORACLE-L=0A>Sent: Wednesday, December 24, 2003 9:59 PM=0A>=0A>=0A>=0A>Hi = All,=0A>=0A>Merry Christmas to all.=0A>=0A>I have this interesting problem.= .=0A>=0A>For this query index ind1 on (c1,c2) columns is getting used.=0A>S= ELECT 'x'=0A> FROM tab ta=0A>WHERE ta.c1=3D'val1';=0A>(gives index ind1 ran= ge scan)=0A>=0A>But for=0A>=0A>SELECT 'x'=0A> FROM tab ta=0A>WHERE ta.c1=3D= 'val1'=0A>AND ta.c3 =3D 'val2';=0A>(gives FTS)=0A>index ind1 is not being u=
sed. c3 is a nonindexed column.=0A>=0A>I have already tried index(ta ind1) = , RULE hints.=0A>=0A>The table and the index are analyzed.=0A>=0A>=0A>=0A>W= hat cud be the reason for that?=0A>=0A>=0A>=0A>Regards,=0A>B S Pradhan=0A>=
=0A>=0A>=0A>=0A>--=0A>Please see the official ORACLE-L FAQ: http://www.oraf=
aq.net=0A>--=0A>Author: zhu chao=0A>   INET: chao_ping_at_vip.163.com=0A>=0A>F=
at City Network Services    -- 858-538-5051 http://www.fatcity.com=0A>San D=
iego, California        -- Mailing list and web hosting services=0A>-------=
--------------------------------------------------------------=0A>To REMOVE=
 yourself from this mailing list, send an E-Mail message=0A>to: ListGuru_at_fa=
tcity.com (note EXACT spelling of 'ListGuru') and in=0A>the message BODY, i=
nclude a line containing: UNSUB ORACLE-L=0A>(or the name of mailing list yo=
u want to be removed from).  You may=0A>also send the HELP command for othe=
r information (like subscribing).=0A
--Next_1072353564---0-203.199.83.28-12769--
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: bhabani s pradhan
  INET: bhabaniindia_at_rediffmail.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu Dec 25 2003 - 05:59:25 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US