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: Scripts for Rebuilding Indexes Nightly on Solaris

RE: Scripts for Rebuilding Indexes Nightly on Solaris

From: Walthour, Jon (GEAE, Compaq) <Jon.walthour_at_ae.ge.com>
Date: Thu, 06 Sep 2001 11:22:56 -0700
Message-ID: <F001.00385AA2.20010906112516@fatcity.com>

First off, checking on a regular basis for indexes that need rebuilding is fine, but don't rebuild all of them every night. Not only is it unnecessary, it can cause lots of problems. Only rebuild the indexes you need to--the ones who are significantly browned, have a significant percentage of deletes, or whose height is significant.

Second, setting up a cron job is indeed a good idea. And David is right that you want to make sure to explicitly set up your environment, but not for the reason he suggests. The problem isn't that the job runs as root. If it were the case that every cron job on a UNIX box ran as root, then that would be a mighty big security hole. The issue is that when running a cron job, the account under which it runs does not automatically get its environment initialized by running .profile as it does when you log in. Thus, the environment must be specifically laid out.

Hope this helps.

Jon Walthour

-----Original Message-----
Sent: Thursday, September 06, 2001 1:33 PM To: Multiple recipients of list ORACLE-L

David -

Use cron. Nightly might be excessive. Kick off a shell script (remember that cron executes as root, so you need to set your environment) and create your own script dynamically (following code is use for backups also) in a manner like:

rebuild_index.sh

#!/bin/ksh

export PATH=$PATH:/u001/app/oracle/product/8.1.7/bin export ORACLE_SID=ifas
export PATH=$PATH:/$ORACLE_HOME/bin
export ORACLE_HOME=/u001/app/oracle/product/8.1.7 export ORACLE_BASE=/u001/app/oracle

sqlplus <<either use a password protection scheme or hardcode your access here> <<username>/<password>>> @/usr/local/bin/rebuild_index

exit

rebuild_index.sql

spool rebuild_index.sql
Select 'Alter index ' || index_name || ' rebuild;' from dba_indexes; # add selection caveats if desired
spool off
!chmod 777 /u014/oradata/ifastrn/rebuild_index.sql @/u014/oradata/ifastrn/rebuild_index

exit

Lots of variations possible.

David A. Barbour
Oracle DBA, OCP
AISD
512-414-1002  

                    Kimberly Smith

                    <kimberly.smith_at_gmd.fu       To:     Multiple recipients
of list ORACLE-L <ORACLE-L_at_fatcity.com>  
                    jitsu.com>                   cc:

                    Sent by:                     Subject:     RE: Scripts
for Rebuilding Indexes Nightly on Solaris   
                    root_at_fatcity.com

 

 

                    09/06/2001 11:57 AM

                    Please respond to

                    ORACLE-L

 

 





Nightly? That is a lot. Are you really entering that much data on a daily basis?

     -----Original Message-----
     From: David Wagoner [mailto:dwagoner_at_arsenaldigital.com]
     Sent: Thursday, September 06, 2001 8:57 AM
     To: Multiple recipients of list ORACLE-L
     Subject: Scripts for Rebuilding Indexes Nightly on Solaris

     Does anyone have any good scripts for rebuilding indexes nightly on
     Solaris UNIX that they'd be willing to share?  Also, in your
     experience is it better to run this through UNIX cron jobs than using
     the Oracle OEM job scheduler?  I suspect the cron job will be the
     favorable answer.


     Thanks in advance,


     David Wagoner
     Oracle DBA



--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author:
  INET: DBarbour_at_austin.isd.tenet.edu

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
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).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Walthour, Jon (GEAE, Compaq)
  INET: Jon.walthour_at_ae.ge.com
Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
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 Sep 06 2001 - 13:22:56 CDT

Original text of this message

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