How to remove chained rows.

  1. Check the number of chanined rows for the objects
  •  ANALYZE TABLE <TABLE_NAME> COMPUTE STATISTICS;
  • SELECT chain_cnt,round(chain_cnt/num_rows*100,2) pct_chained,avg_row_len, pct_free , pct_used
    FROM user_tables
    WHERE table_name = '<TABLE_NAME>';
2. If the pct_chained is high, follow the below steps to remove it.Create a CHAINED_ROWS by exeucting the UTLCHAIN.SQL in $ORACLE_HOME/rdbms/admin or execute the below to create a table
create table CHAINED_ROWS (
  owner_name         varchar2(30),
  table_name         varchar2(30),
  cluster_name       varchar2(30),
  partition_name     varchar2(30),
  subpartition_name  varchar2(30),
  head_rowid         rowid,
  analyze_timestamp  date
);
3. After a CHAINED_ROWS table is created, you specify it in the INTO clause of the ANALYZE statement.
ANALYZE TABLE row_mig_chain_demo LIST CHAINED ROWS;
4. select the rows in the chained rows to view the chained rows
SELECT owner_name,
       table_name,
       head_rowid
 FROM chained_rows;
5. ALTER TABLE <TABLE_NAME> ENABLE ROW MOVEMENT;
6. ALTER TABLE <TABLE_NAME> MOVE TABLESPACE <NEW_TABLESPACE_NAME>;
7. ALTER TABLE <TABLE_NAME> DISABLE ROW MOVEMENT;
8. Rebuild the indexes for the table and gather the statistics for the table.

No comments:

Post a Comment