Option A
ALTER INDEX IX01 REBUILD ONLINE =
ALTER INDEX IX01 COALESCE; + ALTER INDEX IX01 SHRINK SPACE;
ALTER INDEX IX01 COALESCE; + ALTER INDEX IX01 SHRINK SPACE;
Effectivity:
This is highly effective option for table which have many INSERT + DELETE operations.
Space could be reduced in the range of 10%-60%.
The downside:
It is slow... and if index is loaded with DML operation prone to locks.
This is highly effective option for table which have many INSERT + DELETE operations.
Space could be reduced in the range of 10%-60%.
The downside:
It is slow... and if index is loaded with DML operation prone to locks.
Real examples:
872Mb => 387Mb
571Mb => 304Mb
571Mb => 304Mb
Option B
Get DDL
SET LONG 1000
SET PAGESIZE 0
SET LINESIZE 400
COL DDL_CMD FOR A400 WORD_WRAP
SET FEEDBACK OFF
SET HEADING OFF
SELECT DBMS_METADATA.get_dependent_ddl('INDEX','GA_W_COUNTERS_HISTORY', 'MY_USER') AS DDL_CMD FROM DUAL;
Drop and Create the Index using the generated DDL.
Automate the process
crontab
1 6 * * * bash -l /software/oracle/oracle/scripts/rebuild_ix/rebuild_ix.sh
rebuild_ix.sh
#!/bin/bash
WORK_DIR=/software/oracle/oracle/scripts/rebuild_ix
. /etc/sh/orash/oracle_login.sh igt
ORACLE_SID=igt
ORACLE_BASE=/software/oracle
ORACLE_HOME=/software/oracle/121
cd ${WORK_DIR}
sqlplus / as sysdba @rebuild_ix.sql
rebuild_ix.sql
ALTER INDEX USER_A.INDEX_A COALESCE;
ALTER INDEX USER_A.INDEX_A SHRINK SPACE;
ALTER INDEX USER_B.INDEX_B COALESCE;
ALTER INDEX USER_B.INDEX_B SHRINK SPACE;
EXIT;
No comments:
Post a Comment