Return-Path: <root@fatcity.cts.com>
Received: from ensim.rackshack.net (root@localhost)
 by orafaq.net (8.11.6/8.11.6) with ESMTP id gBTMWxY18611
 for <oracle-l@orafaq.net>; Sun, 29 Dec 2002 16:32:59 -0600
X-ClientAddr: 209.68.248.164
Received: from newsfeed.cts.com (newsfeed.cts.com [209.68.248.164])
 by ensim.rackshack.net (8.11.6/8.11.6) with ESMTP id gBTMWxc18606
 for <oracle-l@orafaq.net>; Sun, 29 Dec 2002 16:32:59 -0600
Received: from fatcity.UUCP (uucp@localhost)
 by newsfeed.cts.com (8.9.3/8.9.3) with UUCP id LAA32922;
 Sun, 29 Dec 2002 11:14:57 -0800 (PST)
Received: by fatcity.com (26-Feb-2001/v1.0g-b72/bab) via UUCP id 00523DFE; Sun, 29 Dec 2002 10:33:38 -0800
Message-ID: <F001.00523DFE.20021229103338@fatcity.com>
Date: Sun, 29 Dec 2002 10:33:38 -0800
To: Multiple recipients of list ORACLE-L <ORACLE-L@fatcity.com>
X-Comment: Oracle RDBMS Community Forum
X-Sender: "Tim Gorman" <Tim@SageLogix.com>
Sender: root@fatcity.com
Reply-To: ORACLE-L@fatcity.com
Errors-To: ML-ERRORS@fatcity.com
From: "Tim Gorman" <Tim@SageLogix.com>
Subject: Re: Rebuilding Indexes...
Organization: Fat City Network Services, San Diego, California
X-ListServer: v1.0g, build 72; ListGuru (c) 1996-2001 Bruce A. Bergman
Precedence: bulk
Mime-Version: 1.0
Content-Type: multipart/alternative;	boundary="----=_NextPart_000_027B_01C2AF2D.C828EE70"
------=_NextPart_000_027B_01C2AF2D.C828EE70
Content-Type: text/plain;
 charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Arup,

Excellent practice!  I have written much the same scripts, except I use =
them as an extension to STATSPACK and named the resulting persistent =
table CSTATS$INDEX_STATS.  Nevertheless, I'm curious about the formula =
and will test it out.  I'm a little concerned about the HEIGHT > 3 in =
the WHERE clause, as even "small" indexes can go awry (i.e. HEIGHT <=3D =
3 can still involve hundreds of thousands of rows and thousands of =
blocks)...

Another use for data from INDEX_STATS -- when the value in the =
BLKS_GETS_PER_ACCESS column exceeds several hundred or several thousand =
blocks, you have to question the effectiveness of the B*Tree index =
itself and whether or not it should be dropped.  Chances are good that =
the CBO is ignoring it anyway, so you are paying for the storage costs =
of the index and the processing costs of maintaining it, but not using =
it.  By no means is it open-and-shut that the index should be dropped -- =
there might be SQL statements effciently using the index to take =
advantage of skewed data distribution -- but it should be researched and =
considered for the old "drop kick" nonetheless.

Thanks again!

-Tim
  ----- Original Message -----=20
  From: Arup Nanda=20
  To: Multiple recipients of list ORACLE-L=20
  Sent: Saturday, December 28, 2002 9:08 PM
  Subject: Re: Rebuilding Indexes...


  Jared,

  Did you attach the scripts?

  I use the index rebuilding regularly for certain applications where =
buffer busy waits are prevalent. No, let's not go there why the buffer =
busy waits occur and whether reverse key indexes would help. All these =
are paths well trodden. I use a home grown setup where I ANALYZE =
VALIDATE STRUCTURE each index and immediately store the INDEX_STATS rw =
in a table called INDCHK_INDEX_STATS. Then I use the following script to =
identify the potential indexes candidate for rebuilding. The Height, =
"Compression Factor", Delete% and "Hole Factor" as calculated below =
provide an indication whether the index can be considered to be rebuilt. =
There is no hard threshold value for each, based on all three, I decide =
whether the index needs to be rebuilt.

  Finally, how did I come up with the seemingly labyrinthine formulae =
below? Parts of them are "stolen" from the OEM tool's index check =
program. I snooped around when the tool was analyzing the indexes and =
captured the code, modified to some extent and placed in a nice script. =
It works for me. The indexes are placed in LMT with non-uniform extents =
and the database is 8.1.7.4.

  Yes, I know this will probably spark all sorts of reaction; but I =
would appreciate any feedback on the process.

  Arup Nanda

  col name format a30 head "Index Name"
  col comp_factor head "Compactness"
  col hole_factor format 9999 head "Hole"
  col del_pct format 9999 head "Del%"
  col height format 99999 head "Height"
  SELECT NAME, HEIGHT,=20
   DECODE(HEIGHT, 1, 100,=20
    FLOOR(((LF_ROWS_LEN - DEL_LF_ROWS_LEN) * 100) /=20
    (LF_BLK_LEN * LF_BLKS))) Comp_Factor,=20
   DECODE(HEIGHT, 1, 0, DECODE(LF_ROWS - DEL_LF_ROWS, 0, 1,=20
    DECODE(SIGN(CEIL(LOG(BR_BLK_LEN / (BR_ROWS_LEN / BR_ROWS),=20
    LF_BLK_LEN /=20
    ((LF_ROWS_LEN - DEL_LF_ROWS_LEN) /=20
    (LF_ROWS - DEL_LF_ROWS))))) - HEIGHT, -1, 1, 0))) +
    DECODE(LF_ROWS_LEN, 0, 0,=20
    FLOOR((DEL_LF_ROWS_LEN/LF_ROWS_LEN) * 100)) Hole_Factor,
    round(decode(lf_rows,0,0,100*DEL_LF_ROWS/LF_ROWS),0) del_pct
  FROM INDCHK_INDEX_STATS
  where height > 3
  or DECODE(HEIGHT, 1, 100,
          FLOOR(((LF_ROWS_LEN - DEL_LF_ROWS_LEN) * 100) /
          (LF_BLK_LEN * LF_BLKS)))  < 80
  or DECODE(HEIGHT, 1, 0, DECODE(LF_ROWS - DEL_LF_ROWS, 0, 1,
          DECODE(SIGN(CEIL(LOG(BR_BLK_LEN / (BR_ROWS_LEN / BR_ROWS),
          LF_BLK_LEN /
          ((LF_ROWS_LEN - DEL_LF_ROWS_LEN) /
          (LF_ROWS - DEL_LF_ROWS))))) - HEIGHT, -1, 1, 0))) +
          DECODE(LF_ROWS_LEN, 0, 0,
          FLOOR((DEL_LF_ROWS_LEN/LF_ROWS_LEN) * 100)) > 10
  or decode(lf_rows,0,0,100*DEL_LF_ROWS/LF_ROWS) > 9
  order by 3 desc, 2, 1
  /




  ----- Original Message -----=20
  From: "Jared Still" <jkstill@cybcon.com>
  To: "Multiple recipients of list ORACLE-L" <ORACLE-L@fatcity.com>
  Sent: Thursday, December 26, 2002 10:13 PM
  Subject: Re: Rebuilding Indexes...


  >=20
  > Though I have published a script for determining indexes that
  > need to be rebuilt, and then rebuilding them,  I have to say that
  > this is almost never necessary.
  >=20
  > Why are you rebuilding indexes?  About the only reason for ever
  > doing so is that the BLEVEL >=3D 5.
  >=20
  > goto asktom.oracle.com, and do a search on 'index rebuild'.
  >=20
  > Currently, the third article may be of interest.
  >=20
  > Jared
  >=20
  > On Thursday 26 December 2002 12:24, Richard Huntley wrote:
  > > Anyone have any useful scripts for doing this?
  > >
  > > TIA,
  > > Rich
  >=20
  > ----------------------------------------
  > Content-Type: text/html; charset=3D"iso-8859-1"; name=3D"Attachment: =
1"
  > Content-Transfer-Encoding: 7bit
  > Content-Description:=20
  > ----------------------------------------
  > --=20
  > Please see the official ORACLE-L FAQ: http://www.orafaq.net
  > --=20
  > Author: Jared Still
  >   INET: jkstill@cybcon.com
  >=20
  > 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@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).
  >=20

------=_NextPart_000_027B_01C2AF2D.C828EE70
Content-Type: text/html;
 charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2722.900" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Arup,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Excellent practice!&nbsp; I have =
written&nbsp;much=20
the same scripts, except I use them as an extension to STATSPACK and =
named the=20
resulting persistent&nbsp;table CSTATS$INDEX_STATS.&nbsp; Nevertheless, =
I'm=20
curious about the formula and will test it out.&nbsp; I'm a little =
concerned=20
about the HEIGHT &gt; 3 in the WHERE clause, as even "small" indexes can =
go=20
awry&nbsp;(i.e. HEIGHT &lt;=3D 3 can still involve hundreds of thousands =
of rows=20
and thousands of blocks)...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Another use for data from INDEX_STATS =
-- when the=20
value in the BLKS_GETS_PER_ACCESS column&nbsp;exceeds several hundred or =

several&nbsp;thousand blocks, you have to question the effectiveness =
of&nbsp;the=20
B*Tree index itself&nbsp;and whether or not it should be dropped.&nbsp; =
Chances=20
are good that the CBO is ignoring it anyway, so you are paying for the =
storage=20
costs of the index and the processing costs of maintaining it, but not =
using=20
it.&nbsp; By no means is it open-and-shut that the index should be =
dropped --=20
there might be SQL statements effciently&nbsp;using the index to take =
advantage=20
of skewed data distribution -- but it should be researched and =
considered for=20
the old "drop kick" nonetheless.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks again!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-Tim</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Darupnanda@hotmail.com =
href=3D"mailto:arupnanda@hotmail.com">Arup=20
  Nanda</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
title=3DORACLE-L@fatcity.com=20
  href=3D"mailto:ORACLE-L@fatcity.com">Multiple recipients of list =
ORACLE-L</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Saturday, December 28, =
2002 9:08=20
  PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Re: Rebuilding =
Indexes...</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=3DArial size=3D2>Jared,</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Did you attach the =
scripts?</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>I use the index =
rebuilding&nbsp;regularly for=20
  certain applications where buffer busy waits&nbsp;are prevalent. No, =
let's not=20
  go there why the buffer busy waits occur and whether reverse key =
indexes would=20
  help. All these are&nbsp;paths well trodden. I use a home grown setup =
where I=20
  ANALYZE VALIDATE STRUCTURE each index and immediately store the =
INDEX_STATS rw=20
  in a table called INDCHK_INDEX_STATS. Then I use the following script =
to=20
  identify the potential indexes candidate for rebuilding. The Height,=20
  "Compression Factor", Delete%&nbsp;and "Hole Factor" as calculated =
below=20
  provide an indication whether the index can be considered to be =
rebuilt. There=20
  is no hard threshold value for each, based on all three, I decide =
whether the=20
  index needs to be rebuilt.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Finally, how did I come up with the =
seemingly=20
  labyrinthine formulae below?&nbsp;Parts of them&nbsp;are "stolen" from =
the OEM=20
  tool's index check program. I snooped around when the tool was =
analyzing the=20
  indexes and captured the code, modified to some extent and placed in a =
nice=20
  script. It works for me. The indexes are placed in LMT with =
non-uniform=20
  extents and the database is 8.1.7.4.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Yes, I know this will probably spark =
all sorts of=20
  reaction; but I would appreciate any feedback on the =
process.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Arup Nanda</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>col name format a30 head "Index =
Name"<BR>col=20
  comp_factor head "Compactness"<BR>col hole_factor format 9999 head=20
  "Hole"<BR>col del_pct format 9999 head "Del%"<BR>col height format =
99999 head=20
  "Height"<BR>SELECT NAME, HEIGHT, <BR>&nbsp;DECODE(HEIGHT, 1, 100,=20
  <BR>&nbsp;&nbsp;FLOOR(((LF_ROWS_LEN - DEL_LF_ROWS_LEN) * 100) /=20
  <BR>&nbsp;&nbsp;(LF_BLK_LEN * LF_BLKS))) Comp_Factor, =
<BR>&nbsp;DECODE(HEIGHT,=20
  1, 0, DECODE(LF_ROWS - DEL_LF_ROWS, 0, 1,=20
  <BR>&nbsp;&nbsp;DECODE(SIGN(CEIL(LOG(BR_BLK_LEN / (BR_ROWS_LEN / =
BR_ROWS),=20
  <BR>&nbsp;&nbsp;LF_BLK_LEN / <BR>&nbsp;&nbsp;((LF_ROWS_LEN - =
DEL_LF_ROWS_LEN)=20
  / <BR>&nbsp;&nbsp;(LF_ROWS - DEL_LF_ROWS))))) - HEIGHT, -1, 1, 0)))=20
  +<BR>&nbsp;&nbsp;DECODE(LF_ROWS_LEN, 0, 0,=20
  <BR>&nbsp;&nbsp;FLOOR((DEL_LF_ROWS_LEN/LF_ROWS_LEN) * 100))=20
  =
Hole_Factor,<BR>&nbsp;&nbsp;round(decode(lf_rows,0,0,100*DEL_LF_ROWS/LF_R=
OWS),0)=20
  del_pct<BR>FROM INDCHK_INDEX_STATS<BR>where height &gt; 3<BR>or =
DECODE(HEIGHT,=20
  1, 100,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
FLOOR(((LF_ROWS_LEN -=20
  DEL_LF_ROWS_LEN) * 100) =
/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  (LF_BLK_LEN * LF_BLKS)))&nbsp; &lt; 80<BR>or DECODE(HEIGHT, 1, 0,=20
  DECODE(LF_ROWS - DEL_LF_ROWS, 0,=20
  1,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  DECODE(SIGN(CEIL(LOG(BR_BLK_LEN / (BR_ROWS_LEN /=20
  BR_ROWS),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LF_BLK_LEN=20
  /<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((LF_ROWS_LEN -=20
  DEL_LF_ROWS_LEN) /<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
(LF_ROWS -=20
  DEL_LF_ROWS))))) - HEIGHT, -1, 1, 0)))=20
  +<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DECODE(LF_ROWS_LEN, 0, =

  0,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  FLOOR((DEL_LF_ROWS_LEN/LF_ROWS_LEN) * 100)) &gt;=20
  10<BR>or&nbsp;decode(lf_rows,0,0,100*DEL_LF_ROWS/LF_ROWS) &gt; =
9<BR>order by 3=20
  desc, 2, 1<BR>/</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>----- Original Message ----- </FONT>
  <DIV><FONT face=3DArial size=3D2>From: "Jared Still" &lt;</FONT><A=20
  href=3D"mailto:jkstill@cybcon.com"><FONT face=3DArial=20
  size=3D2>jkstill@cybcon.com</FONT></A><FONT face=3DArial =
size=3D2>&gt;</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>To: "Multiple recipients of list =
ORACLE-L"=20
  &lt;</FONT><A href=3D"mailto:ORACLE-L@fatcity.com"><FONT face=3DArial=20
  size=3D2>ORACLE-L@fatcity.com</FONT></A><FONT face=3DArial=20
size=3D2>&gt;</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Sent: Thursday, December 26, 2002 =
10:13=20
  PM</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Subject: Re: Rebuilding=20
  Indexes...</FONT></DIV></DIV>
  <DIV><FONT face=3DArial><BR><FONT size=3D2></FONT></FONT></DIV><FONT =
face=3DArial=20
  size=3D2>&gt; <BR>&gt; Though I have published a script for =
determining indexes=20
  that<BR>&gt; need to be rebuilt, and then rebuilding them,&nbsp; I =
have to say=20
  that<BR>&gt; this is almost never necessary.<BR>&gt; <BR>&gt; Why are =
you=20
  rebuilding indexes?&nbsp; About the only reason for ever<BR>&gt; doing =
so is=20
  that the BLEVEL &gt;=3D 5.<BR>&gt; <BR>&gt; goto asktom.oracle.com, =
and do a=20
  search on 'index rebuild'.<BR>&gt; <BR>&gt; Currently, the third =
article may=20
  be of interest.<BR>&gt; <BR>&gt; Jared<BR>&gt; <BR>&gt; On Thursday 26 =

  December 2002 12:24, Richard Huntley wrote:<BR>&gt; &gt; Anyone have =
any=20
  useful scripts for doing this?<BR>&gt; &gt;<BR>&gt; &gt; TIA,<BR>&gt; =
&gt;=20
  Rich<BR>&gt; <BR>&gt; ----------------------------------------<BR>&gt; =

  Content-Type: text/html; charset=3D"iso-8859-1"; name=3D"Attachment: =
1"<BR>&gt;=20
  Content-Transfer-Encoding: 7bit<BR>&gt; Content-Description: <BR>&gt;=20
  ----------------------------------------<BR>&gt; -- <BR>&gt; Please =
see the=20
  official ORACLE-L FAQ: </FONT><A href=3D"http://www.orafaq.net"><FONT =
face=3DArial=20
  size=3D2>http://www.orafaq.net</FONT></A><BR><FONT face=3DArial =
size=3D2>&gt; --=20
  <BR>&gt; Author: Jared Still<BR>&gt; &nbsp; INET: </FONT><A=20
  href=3D"mailto:jkstill@cybcon.com"><FONT face=3DArial=20
  size=3D2>jkstill@cybcon.com</FONT></A><BR><FONT face=3DArial =
size=3D2>&gt; <BR>&gt;=20
  Fat City Network Services&nbsp;&nbsp;&nbsp; -- 858-538-5051 </FONT><A=20
  href=3D"http://www.fatcity.com"><FONT face=3DArial=20
  size=3D2>http://www.fatcity.com</FONT></A><BR><FONT face=3DArial =
size=3D2>&gt; San=20
  Diego, California&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- Mailing =
list=20
  and web hosting services<BR>&gt;=20
  =
---------------------------------------------------------------------<BR>=
&gt;=20
  To REMOVE yourself from this mailing list, send an E-Mail =
message<BR>&gt; to:=20
  </FONT><A href=3D"mailto:ListGuru@fatcity.com"><FONT face=3DArial=20
  size=3D2>ListGuru@fatcity.com</FONT></A><FONT face=3DArial size=3D2> =
(note EXACT=20
  spelling of 'ListGuru') and in<BR>&gt; the message BODY, include a =
line=20
  containing: UNSUB ORACLE-L<BR>&gt; (or the name of mailing list you =
want to be=20
  removed from).&nbsp; You may<BR>&gt; also send the HELP command for =
other=20
  information (like subscribing).<BR>&gt; =
</FONT></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_027B_01C2AF2D.C828EE70--

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Tim Gorman
  INET: Tim@SageLogix.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@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).

