Return-Path: <oracle-l-bounce@freelists.org>
Delivered-To: 2-oracle-l@orafaq.com
Received: (qmail 15889 invoked from network); 18 Sep 2007 04:57:13 -0500
Received: from freelists-180.iquest.net (HELO turing.freelists.org) (206.53.239.180)
  by 69.64.49.119 with SMTP; 18 Sep 2007 04:57:13 -0500
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id E58FC75B4CF;
 Tue, 18 Sep 2007 05:57:11 -0400 (EDT)
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 08211-05; Tue, 18 Sep 2007 05:57:11 -0400 (EDT)
Received: from turing (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 535D475B4C5;
 Tue, 18 Sep 2007 05:57:11 -0400 (EDT)
Received: with ECARTIS (v1.0.0; list oracle-l); Tue, 18 Sep 2007 05:12:11 -0400 (EDT)
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id D09AE75AFF4
 for <oracle-l@freelists.org>; Tue, 18 Sep 2007 05:12:10 -0400 (EDT)
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 02534-06 for <oracle-l@freelists.org>;
 Tue, 18 Sep 2007 05:12:10 -0400 (EDT)
Received: from Kecgate03.infosys.com (kecgate03.progeon.com [220.227.179.21])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 4838975AF69
 for <oracle-l@freelists.org>; Tue, 18 Sep 2007 05:12:08 -0400 (EDT)
Received: from INDHUBBHS02.ad.infosys.com ([192.168.200.82]) by Kecgate03.infosys.com with InterScan Message Security Suite; Tue, 18 Sep 2007 14:45:04 +0530
Received: from blrkechub01.ad.infosys.com ([10.66.236.41]) by INDHUBBHS02.ad.infosys.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Tue, 18 Sep 2007 14:42:05 +0530
Received: from BLRKECMBX02.ad.infosys.com ([10.66.236.22]) by
 blrkechub01.ad.infosys.com ([10.66.236.41]) with mapi; Tue, 18 Sep 2007
 14:42:05 +0530
From: VIVEK_SHARMA <VIVEK_SHARMA@infosys.com>
To: "oracle-l@freelists.org" <oracle-l@freelists.org>
Date: Tue, 18 Sep 2007 14:42:04 +0530
Subject: Wrong index being used ... Basic SQL Qs
Thread-Topic: Wrong index being used ... Basic SQL Qs
Message-ID: <69E1360E54B50C4A828A136C158E474201DC2C9487@BLRKECMBX02.ad.infosys.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
acceptlanguage: en-US
Content-Type: multipart/alternative; boundary="_000_69E1360E54B50C4A828A136C158E474201DC2C9487BLRKECMBX02ad_"
MIME-Version: 1.0
X-OriginalArrivalTime: 18 Sep 2007 09:12:05.0813 (UTC) FILETIME=[FB9CEE50:01C7F9D3]
X-archive-position: 1642
X-ecartis-version: Ecartis v1.0.0
Sender: oracle-l-bounce@freelists.org
Errors-to: oracle-l-bounce@freelists.org
X-original-sender: VIVEK_SHARMA@infosys.com
Precedence: normal
Reply-to: VIVEK_SHARMA@infosys.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
X-Virus-Scanned: Debian amavisd-new at localhost.localdomain
--_000_69E1360E54B50C4A828A136C158E474201DC2C9487BLRKECMBX02ad_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable


Folks

During an Internal Benchmark Run, following SQL Query is using the Wrong=
 index idx_inst_num which has very Low Cardinality.ALL Rows of the Table=
 have inst_num value =3D '89651' (1 Constant Value).

Usage of Unique index IDX_INW_CLG_INST_TABLE would be preferred over=
 idx_inst_num index as Cardinality of (sol_id, zone_code, zone_date,=
 zone_srl_num, bank_id ) Combination is much better than (inst_num)

NOTE - ICI Table is partitioned on SOL_ID field  & has only 81636  Rows.

Qs Will Creating Histogram on inst_num field make the optimizer avoid usage=
 of the respective idx_inst_num index choose the Correct index i.e.=
 IDX_INW_CLG_INST_TABLE ? Any Other Ideas?
NOTE - SQL Code Change can Not be made.

Indexes on ICI Table:-

Unique IDX_INW_CLG_INST_TABLE index - Locally Prefixed Partitioned Index -=
 (sol_id, zone_code, zone_date, zone_srl_num, bank_id )

idx_inst_num index - (inst_num)



Thanks indeed


P.S. SQL Query

SELECT  COUNT(*) FROM ICI
WHERE ICI.BANK_ID =3D  '01'
AND  SOL_ID =3D '0049'
AND ZONE_CODE =3D  'PECINW0008'
AND ZONE_DATE =3D TO_DATE( '08-05-2003'  ,'DD-MM-YYYY HH24:MI:SS')
AND INST_NUM =3D  '89651'

Misses in library cache during parse: 0
Optimizer mode: CHOOSE
Parsing user id: 35  (TBAADM)

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=3D3 pr=3D0 pw=3D0 time=3D87 us)
      0   TABLE ACCESS BY GLOBAL INDEX ROWID INW_CLG_INST_TABLE PARTITION:=
 2 2 (cr=3D3 pr=3D0 p
w=3D0 time=3D70 us)
      0    INDEX RANGE SCAN IDX_INST_NUM (cr=3D3 pr=3D0 pw=3D0 time=3D65=
 us)(object id 28758)


**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended=
 solely for the use of the addressee(s). If you are not the intended=
 recipient, please notify the sender by e-mail and delete the original=
 message. Further, you are not to copy, disclose, or distribute this e-mail=
 or its contents to any other person and any such actions are unlawful.=
 This e-mail may contain viruses. Infosys has taken every reasonable=
 precaution to minimize this risk, but is not liable for any damage you may=
 sustain as a result of any virus in this e-mail. You should carry out your=
 own virus checks before opening the e-mail or attachment. Infosys reserves=
 the right to monitor and review the content of all messages sent to or=
 from this e-mail address. Messages sent to or from this e-mail address may=
 be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
--_000_69E1360E54B50C4A828A136C158E474201DC2C9487BLRKECMBX02ad_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=
=3D"urn:schemas-microsoft-com:office:office" xmlns:w=
=3D"urn:schemas-microsoft-com:office:word" xmlns=
=3D"http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=
=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Courier New";}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:Arial;
	color:windowtext;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3DArial><span style=
=3D'font-size:
10.0pt;font-family:Arial;color:purple'>Folks<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3DArial><span style=
=3D'font-size:
10.0pt;font-family:Arial;color:purple'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3DArial><span style=
=3D'font-size:
10.0pt;font-family:Arial;color:purple'>During an Internal Benchmark Run,=
 following
SQL Query is using the Wrong index idx_inst_num which has very Low=
 Cardinality.ALL
Rows of the Table have inst_num value =3D '89651' (1 Constant=
 Value).<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3DArial><span style=
=3D'font-size:
10.0pt;font-family:Arial;color:purple'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3DArial><span style=
=3D'font-size:
10.0pt;font-family:Arial;color:purple'>Usage of Unique index=
 IDX_INW_CLG_INST_TABLE
would be preferred over idx_inst_num index as Cardinality of (sol_id,
zone_code, zone_date, zone_srl_num, bank_id ) Combination is much better=
 than (inst_num)<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3DArial><span style=
=3D'font-size:
10.0pt;font-family:Arial;color:purple'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3DArial><span style=
=3D'font-size:
10.0pt;font-family:Arial;color:purple'>NOTE - ICI Table is partitioned on
SOL_ID field &nbsp;&amp; has only 81636&nbsp;=
 Rows.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3DArial><span style=
=3D'font-size:
10.0pt;font-family:Arial;color:purple'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><b><font size=3D2 color=3Dpurple face=3DArial><span
style=
=3D'font-size:10.0pt;font-family:Arial;color:purple;font-weight:bold'>Qs
Will Creating Histogram on inst_num field make the optimizer avoid usage of=
 the
respective idx_inst_num index choose the Correct index i.e.=
 IDX_INW_CLG_INST_TABLE
? Any Other Ideas?<o:p></o:p></span></font></b></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3DArial><span style=
=3D'font-size:
10.0pt;font-family:Arial;color:purple'>NOTE &#8211; SQL Code Change can Not=
 be
made.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3DArial><span style=
=3D'font-size:
10.0pt;font-family:Arial;color:purple'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><b><font size=3D2 color=3Dpurple face=3DArial><span
style=
=3D'font-size:10.0pt;font-family:Arial;color:purple;font-weight:bold'>Index=
es
on ICI Table:-<o:p></o:p></span></font></b></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dpurple face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial;color:purple'>Unique
IDX_INW_CLG_INST_TABLE index &#8211; Locally Prefixed Partitioned Index -
(sol_id, zone_code, zone_date, zone_srl_num, bank_id=
 )<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dpurple face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial;color:purple'>idx_inst_num=
 index -
(inst_num)<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dpurple face=3DArial><span
style=
=3D'font-size:10.0pt;font-family:Arial;color:purple'><o:p>&nbsp;</o:p></spa=
n></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dpurple face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial;color:purple'>Thanks=
 indeed<o:p></o:p></span></font></p>

<p class=3DMsoPlainText><font size=3D2 color=3Dpurple face=3DArial><span
style=
=3D'font-size:10.0pt;font-family:Arial;color:purple'><o:p>&nbsp;</o:p></spa=
n></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:purple'>P.S. SQL=
 Query<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:purple'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:purple'>SELECT&nbsp;
COUNT(*) FROM ICI<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:purple'>WHERE
ICI.BANK_ID =3D&nbsp; '01'<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:purple'>AND&nbsp;=
 SOL_ID =3D
'0049'<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:purple'>AND=
 ZONE_CODE
=3D&nbsp; 'PECINW0008'<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:purple'>AND=
 ZONE_DATE =3D
TO_DATE( '08-05-2003'&nbsp; ,'DD-MM-YYYY=
 HH24:MI:SS')<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:purple'>AND=
 INST_NUM =3D&nbsp;
'89651'<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:purple'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:purple'>Misses in
library cache during parse: 0<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:purple'>Optimizer=
 mode:
CHOOSE<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:purple'>Parsing=
 user
id: 35&nbsp; (TBAADM)<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:purple'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:purple'>Rows&nbsp;&nbsp;&nbsp;&nbsp; Row
Source Operation<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:purple'>-------&nbsp;
---------------------------------------------------<o:p></o:p></span></font=
></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:purple'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp; SORT
AGGREGATE (cr=3D3 pr=3D0 pw=3D0 time=3D87 us)<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:purple'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; TABLE
ACCESS BY GLOBAL INDEX ROWID INW_CLG_INST_TABLE PARTITION: 2 2 (cr=3D3 pr=
=3D0 p<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:purple'>w=3D0=
 time=3D70 us)<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dpurple face=3D"Courier=
 New"><span
style=3D'font-size:10.0pt;font-family:"Courier=
 New";color:purple'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;
INDEX RANGE SCAN <b><span style=
=3D'font-weight:bold'>IDX_INST_NUM</span></b>
(cr=3D3 pr=3D0 pw=3D0 time=3D65 us)(object id=
 28758)<o:p></o:p></span></font></p>

</div>

</body>

</html>

<table><tr><td bgcolor=3D#ffffff><font color=3D#000000>****************=
 CAUTION - Disclaimer *****************<br>
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended=
 solely for the use of the addressee(s). If you are not the intended=
 recipient, please notify the sender by e-mail and delete the original=
 message. Further, you are not to copy, disclose, or distribute this e-mail=
 or its contents to any other person and any such actions are unlawful.=
 This e-mail may contain viruses. Infosys has taken every reasonable=
 precaution to minimize this risk, but is not liable for any damage you may=
 sustain as a result of any virus in this e-mail. You should carry out your=
 own virus checks before opening the e-mail or attachment. Infosys reserves=
 the right to monitor and review the content of all messages sent to or=
 from this e-mail address. Messages sent to or from this e-mail address may=
 be stored on the Infosys e-mail system.<br>
***INFOSYS******** End of Disclaimer ********INFOSYS***<br>
</font></td></tr></table>
--_000_69E1360E54B50C4A828A136C158E474201DC2C9487BLRKECMBX02ad_--

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


