Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: concatenated index
Hi
SQL> select /*+ RULE */
2 A,B,C,D
3 from test
4 where b=113
5 and c=114
6 and a= 112
7 /
A B C D
---------- ---------- ---------- ------------------------------ 112 113 114 test
Thanks in advance
Novice
No more Oracle certifiable DBA
From: "Mark Richard" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: Multiple recipients of list ORACLE-L <[EMAIL PROTECTED]>
Subject: Re: concatenated index
Date: Mon, 07 Jul 2003 20:09:24 -0800
MIME-Version: 1.0
Received: from www3.fatcity.com ([66.27.56.212]) by
mc7-f35.law1.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Mon, 7 Jul
2003 20:25:59 -0700
Received: (from [EMAIL PROTECTED])by www3.fatcity.com (8.11.6/8.11.6) id
h683EOP30813for [EMAIL PROTECTED]; Mon, 7 Jul 2003 20:14:24 -0700
Received: by fatcity.com (05-Jun-2003/v1.0g-b73/bab) via fatcity.com id
005C3BC9; Mon, 07 Jul 2003 20:09:24 -0800
X-Message-Info: JGTYoYF78jEHjJx36Oi8+Q1OJDRSDidP
Message-ID: <[EMAIL PROTECTED]>
X-Comment: Oracle RDBMS Community Forum
X-Sender: "Mark Richard" <[EMAIL PROTECTED]>
Sender: [EMAIL PROTECTED]
Errors-To: [EMAIL PROTECTED]
Organization: Fat City Network Services, San Diego, California
X-ListServer: v1.0g, build 73; ListGuru (c) 1996-2003 Bruce A. Bergman
Precedence: bulk
Return-Path: [EMAIL PROTECTED]
X-OriginalArrivalTime: 08 Jul 2003 03:25:59.0669 (UTC)
FILETIME=[A6C41250:01C34500]
The order of the where clause is not important. Including the leading
(first) columns in the index is. If you remove the "a = ?" element from
any of the queries then it may stop using the index. Oracle is smart
enough to look at the entire where clause and work out what it can do to
achieve the result quickest.
You may be thinking on the rule based optimisor where the ordering of where
clauses is significant - for cost based optimisor the order is essentially
irrelevant.
Regards,
Mark.
"Novice DBA" <[EMAIL PROTECTED] To: Multiple recipients of list ORACLE-L <[EMAIL PROTECTED]> l.com> cc: Sent by: Subject: concatenated index [EMAIL PROTECTED] .com 08/07/2003 13:44 Please respond to ORACLE-L Dear all, I have a basic doubt. I grew up (in Oracle) believing that for theconcatenated indexes to be used by a query the ordering of the columns in the where clause was very important. But now I have doubts I have a table test and a composite index on it. CREATE TABLE TEST (
A NUMBER, B NUMBER, C NUMBER,
Then tried some queries with explain plan. There is only one row which
matches this criteria.
SQL> explain plan for
2 select * from test
3 where a= 112
4 and b=113
5 and c=114;
Explained.
SQL> @plan
Plan Table
| Operation | Name | Rows | Bytes| Cost | Pstart|Pstop |
SQL> explain plan for
2 select * from test
3 where a= 112
4 and c=114
5 and b=113;
Explained.
SQL> @plan
Plan Table
| Operation | Name | Rows | Bytes| Cost | Pstart|Pstop |
SQL> explain plan for
2 select * from test
3 where b=113
4 and a= 112
5 and c=114;
Explained.
SQL> @plan
Plan Table
| Operation | Name | Rows | Bytes| Cost | Pstart|Pstop |
SQL> explain plan for
2 select * from test
3 where b=113
4 and c=114
5 and a= 112;
Explained.
SQL> @plan
Plan Table
| Operation | Name | Rows | Bytes| Cost | Pstart|Pstop |
SQL> explain plan for
2 select * from test
3 where b=113
4 and c=114;
Explained.
SQL> @plan
Plan Table
| Operation | Name | Rows | Bytes| Cost | Pstart|Pstop |
Now I am at loss. I know this is something very basic. But I am unable to
understand why the index is being used even when the order of the columns
in
the where clause is changed.
Oracle version 8.1.7.2.
Please enlighten me
Thanks in advance
Novice
No more Oracle Certifiable DBA
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Novice DBA INET: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-LReceived on Mon Jul 07 2003 - 23:01:17 CDT
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing). <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Privileged/Confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply e-mail or by telephone on (61 3) 9612-6999. Please advise immediately if you or your employer does not consent to Internet e-mail for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of Transurban City Link Ltd shall be understood as neither given nor endorsed by it. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Privileged/Confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such a case, you should destroy this message and kindly notify the sender by reply e-mail or by telephone on (03) 9612-6999 or (61) 3 9612-6999. Please advise immediately if you or your employer does not consent to Internet e-mail for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of Transurban Infrastructure Developments Limited and CityLink Melbourne Limited shall be understood as neither given nor endorsed by them. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Mark Richard INET: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] (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). _________________________________________________________________ MSN give you more space! 5 times more storage. http://join.msn.com/?page=dept/home&pgmarket=en-xu Do more for less. -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Novice DBA INET: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] (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).