Вы находитесь на странице: 1из 2

Rebuilding indexes

Rebuilding indexes is mainly required to be done to improve the performance of t


he sql queries that uses those indexes. This index rebuilding will not only impr
ove the performance but will also help us in reclaiming free space from particul
ar indexes.

Brief description of rebuilding indexes:


The rebuilding of indexes will improve the performance of sql qu
ery output as mentioned above. The big index rebuilding requires a lot temp spac
e for rebuilding of indexes. Hence enough free space should be made available in
the TEMP tablespace of the database.

Procedure to rebuild index:


1. First defer the standby archive destination in dc so that the archives d
uring rebuilding are not moved to drc. Because during rebuilding if archives are
archived to drc then rebuilding will take lot of time in completing. Archives c
an be moved to drc through some scripts but not through dataguard.
Alter system set log_archive_dest_state_3=defer scope=both sid= *
Alter system checkpoint;
Alter system archive log current;
Alter system archive log current;

2. Make space in Archive destination at DC around 60 GB should be free for


index rebuilding archives to be generated.
/xyz_bancs/oraarch/c012band
/xyz_bancs/oraarch/c012band_copy

3. Check free tablespace in the index tablespace.


The free space in the tablespace where the index resides should be at least 10GB
more than the index segment size.
Select segment_name, tablespace_name, sum (bytes)/1024/1024 from dba_segments wh
ere segment_name= &a group by segment_name, tablespace_name;
This will prompt you for segment_name, enter the segment name and it will provid
e you the output with segment_name, tablespace_name and size of the index.

4. Check the free space in TEMP tablespace:


Select tablespace_name, sum(bytes_free/1024/1024), sum(bytes_used/1024/1024) fr
om v$temp_space_header where tablespace_name='TEMP' group by tablespace_name ;

5. Add another tempfile in TEMP tablespace in a file system:


alter tablespace temp add tempfile
/xyz/oraarch_alt/tempfiles/c012band_TEMP_003.dbf' SIZE 15000M;
alter tablespace temp add tempfile
/xyz/oraarch_alt/tempfiles/c012band_TEMP_004.dbf' SIZE 15000M;
6. Now start rebuilding the index:
Connect with sys as sysdba
Set time on
Set timing on
alter index fnsonlc.<index_name> rebuild online parallel 16;
(Do not abort the above command in any case)
Wait for the command to finish
Alter system archive log current;
NOTE: Keep monitoring the temporary space usage from the above select command.
If the space is less then add another tempfile in TEMP tablespace in a file syst
em.
alter index fnsonlc.<index_name> noparallel;
analyze index fnsonlc.<index_name> estimate statistics;
9) After index rebuilding complete. Drop all the temporary datafiles and add the
original tempfiles.
Alter database tempfile /dev/vx/rdsk/xyz_dbday_undo_dg/c012band_TEMP_001.dbf drop;
Alter database tempfile /dev/vx/rdsk/xyz_dbday_undo_dg/c012band_TEMP_002.dbf drop;
Alter database tempfile
/xyz/oraarch_alt/tempfiles/c012band_TEMP_003.dbf drop;
Alter database tempfile
/xyz/oraarch_alt/tempfiles/c012band_TEMP_003.dbf drop;
alter tablespace temp add tempfile
/dev/vx/rdsk/xyz_dbday_undo_dg/c012band_TEMP_001.dbf size 8000M ;
alter tablespace temp add tempfile
/dev/vx/rdsk/xyz_dbday_undo_dg/c012band_TEMP_002.dbf size 8000M ;

Вам также может понравиться