Received: (qmail 17604 invoked from network); 2 Feb 2012 16:00:45 -0600
Received: from freelists-180.iquest.net (HELO turing.freelists.org) (206.53.239.180)
  by static-ip-85-25-126-90.inaddr.ip-pool.com with SMTP; 2 Feb 2012 16:00:40 -0600
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 85A76E8CBEB;
 Thu,  2 Feb 2012 17:00:38 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=freelists.org;
 s=turing; t=1328220038; bh=ltwth5yegZdvPz7IEcTUfoCvmmNSgwVbCPfdpDSL
 O5M=; h=From:To:Date:Subject:Message-ID:References:In-Reply-To:
	 Content-type:Content-Transfer-Encoding:MIME-Version:Sender:
	 Reply-To:List-help:List-unsubscribe:List-Id:List-subscribe:
	 List-owner:List-post:List-archive; b=rLT+gyHzT7nxIleksQgRRSXA22KE5
 2t95pOJ9LFEm8ZclLrn+BBXZJuIqz/H1m70vzGUIZDUjA4EB/oYXLNtAVpiLqZ98m7S
 lciNmRmhP5ItKEz/mopnNmC7YTdKEIb+uPg6Bc4eF8BY07jKbiR3qMQjrLUCSGV8gIa
 iGzW8hO4=
X-Virus-Scanned: Debian amavisd-new at localhost.localdomain
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Y13o+IVH3YBD; Thu,  2 Feb 2012 17:00:38 -0500 (EST)
Received: from turing.freelists.org (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id CA1A7E8CB63;
 Thu,  2 Feb 2012 16:59:54 -0500 (EST)
Received: with ECARTIS (v1.0.0; list oracle-l); Thu, 02 Feb 2012 16:59:13 -0500 (EST)
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 6E494E8CB72
 for <oracle-l@freelists.org>; Thu,  2 Feb 2012 16:59:12 -0500 (EST)
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id QVMdkHWdFi4A for <oracle-l@freelists.org>;
 Thu,  2 Feb 2012 16:59:12 -0500 (EST)
Received: from g5t0006.atlanta.hp.com (g5t0006.atlanta.hp.com [15.192.0.43])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id B1892E8CB65
 for <oracle-l@freelists.org>; Thu,  2 Feb 2012 16:59:11 -0500 (EST)
Received: from G5W2206G.americas.hpqcorp.net (g5w2206g.atlanta.hp.com [16.228.43.185])
 (using TLSv1 with cipher AES128-SHA (128/128 bits))
 (No client certificate requested)
 by g5t0006.atlanta.hp.com (Postfix) with ESMTPS id 4301DC04D
 for <oracle-l@freelists.org>; Thu,  2 Feb 2012 21:59:09 +0000 (UTC)
Received: from G6W0173.americas.hpqcorp.net (16.230.33.182) by
 G5W2206G.americas.hpqcorp.net (16.228.43.185) with Microsoft SMTP Server
 (TLS) id 14.1.289.1; Thu, 2 Feb 2012 21:57:43 +0000
Received: from GVW1337EXC.americas.hpqcorp.net ([16.230.35.3]) by
 G6W0173.americas.hpqcorp.net ([16.230.33.182]) with mapi; Thu, 2 Feb 2012
 21:57:43 +0000
From: "Powell, Mark" <mark.powell2@hp.com>
To: "oracle-l@freelists.org" <oracle-l@freelists.org>
Date: Thu, 2 Feb 2012 21:57:41 +0000
Subject: RE: Concatenated Index Column Order - Does it really matters?
Thread-Topic: Concatenated Index Column Order - Does it really matters?
Message-ID: <7C4BF3B32B80CC44AE37D31B172415937DD6EA8F31@GVW1337EXC.americas.hpqcorp.net>
References: <4EDFD6C9-6B5A-4048-8B37-11D1AA492A72@yahoo.com>
 <1328030723.5907.YahooMailNeo@web36801.mail.mud.yahoo.com>
 <1328215709.95796.YahooMailNeo@web36803.mail.mud.yahoo.com>
In-Reply-To: <1328215709.95796.YahooMailNeo@web36803.mail.mud.yahoo.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
acceptlanguage: en-US
Content-type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0
X-archive-position: 41259
X-ecartis-version: Ecartis v1.0.0
Sender: oracle-l-bounce@freelists.org
Errors-to: oracle-l-bounce@freelists.org
X-original-sender: mark.powell2@hp.com
Precedence: normal
Reply-To: mark.powell2@hp.com
List-help: <mailto:ecartis@freelists.org?Subject=help>
List-unsubscribe: <oracle-l-request@freelists.org?Subject=unsubscribe>
List-software: Ecartis version 1.0.0
List-Id: oracle-l <oracle-l.freelists.org>
X-List-ID: oracle-l <oracle-l.freelists.org>
List-subscribe: <oracle-l-request@freelists.org?Subject=subscribe>
List-owner: <mailto:steve.adams@ixora.com.au>
List-post: <mailto:oracle-l@freelists.org>
List-archive: <http://www.freelists.org/archives/oracle-l>
X-list: oracle-l

No, you should make the "most selected" column the leading column of the multi-column index.  That is if 6 queries reference one or both of the two columns and the 3 queries that reference only one of the columns reference the same column then you normally want that column to be the leading column (providing the data is not badly skewed).

Ever case depends on the data distribution and the actual queries being ran but in general I suggest looking at what columns are referenced and which other indexes you would need to create if you choose a specific order.

The least selective column being first could be beneficial if index compression is used.  Again I find use of this feature has to be judged on a case by case basis.


-----Original Message-----
From: oracle-l-bounce@freelists.org [mailto:oracle-l-bounce@freelists.org] On Behalf Of Antony Raj
Sent: Thursday, February 02, 2012 3:48 PM
To: oracle-l@freelists.org
Subject: Concatenated Index Column Order - Does it really matters?

Hi,
 
I have a table T1 has 35 million rows.The following SQLs (Top 2) and many more runs every day.
 
UPDATE T1 SET AUDIT_FLAG='H' WHERE AUDIT_FLAG='C' AND JOB_ID=(SELECT MAX(JOB_ID) FROM T1 WHERE JOB_ID <> :1);
 
SELECT Z.EMPLID, Z.EMPL_RCD, Z.FIRST_NAME, Z.LAST_NAME, Z.MIDDLE_NAME, Z.COVERAGE_BEGIN_DT, DECODE(Z.EMPL_STATUS, 'U', 'A', Z.EMPL_STATUS), Z.UNION_CD, Z.PAYGROUP, Z.EXPECTED_RETURN_DT, Z.SEX, Z.DEPENDENT_BENEF,
  Z.RELATIONSHIP, Z.NATIONAL_ID, Z.BIRTHDATE, Z.STUDENT, Z.DISABLED, Z.MAR_STATUS, Z.MAR_STATUS_DT, Z.ADDRESS1, Z.ADDRESS2, Z.CITY, Z.STATE,
  Z.POSTAL, Z.COUNTRY, Z.DEDUCTION_BEGIN_DT, Z.COVRG_CD, Z.COVERAGE_ELECT,   Z.TERMINATION_DT, Z.BENEFIT_PLAN, Z.VENDOR_ID, Z.END_DT, Z.ELIG_CONFIG1,   Z.BEGIN_DT, Z.PHONE FROM T1 Z WHERE Z.JOB_ID = ( SELECT MAX(Z1.JOB_ID) FROM T1 Z1 WHERE Z1.EMPLID = Z.EMPLID AND Z1.AUDIT_FLAG ='H') And Z.EMPLID = :1 AND NOT EXISTS ( SELECT 'X' FROM T1 Z2 WHERE Z2.EMPLID = Z.EMPLID AND Z2.DEPENDENT_BENEF = Z.DEPENDENT_BENEF AND   Z2.AUDIT_FLAG = 'C' and AUDIT_ACTN in ('A','C') ) ORDER BY Z.EMPLID;
 
Unique Index Columns:
 
JOB_ID
EMPLID
PLAN_TYPE
DEPENDENT_BENEF
 
I am thinking of adding another index with the following column order to satisfy the top 2 SQLs.
JOB_ID,
AUDIT_FLAG,
EMPLID,
DEPENDENT_BENEF,
AUDIT_ACTN
 
 Column Name                    Null?      Type             NUM_DISTINCT
 ------------------------------ ---------- --------------- ------------
 JOB_ID                         NOT NULL   NUMBER(10,0)             394
 EMPLID                         NOT NULL   VARCHAR2(44)           31366
 PLAN_TYPE                      NOT NULL   VARCHAR2(8)                2
 DEPENDENT_BENEF                NOT NULL   VARCHAR2(8)               14
 AUDIT_ACTN                     NOT NULL   VARCHAR2(4)                3
 AUDIT_FLAG                     NOT NULL   VARCHAR2(4)                3
 
My question is that should I consider the "most selective column" as a leading column?
 
Thanks
--
http://www.freelists.org/webpage/oracle-l


--
http://www.freelists.org/webpage/oracle-l


