Sei sulla pagina 1di 3

1.

DESCRIZIONE DEL PROBLEMA La funzione di Shrinking Database Segments Online una procedura disponibile dalla release 10g di Oracle e utlizzata per rilasciare e compattare gli spazi liberi nei blocchi allocati che si rendono disponibili per altri segmenti nel tablespace. Ove possibile utilizzarla si tratta di una valida ed efficace alterantiva alla riorganizzazione di segmenti , in quelle situazioni ove questo tipo di manutenzione ha lo scopo di recuperare spazio allinterno del database. La tematica a livello di documentazione uffciale Oracle inquadrata tra le attivit di gestione degli spazi a carattere di manutenzione proattiva e pertanto preventiva. Vedi approfondimento 1

2. CAUSA DEL PROBLEMA Si richiede la riorganizzazione di segmenti di database , tabelle e/o indici 3. PAROLE CHIAVE Oracle, shrink segment, reorganization , free space 4. SOLUZIONE

4.1. Verifica dei prerequisiti


4.1.1. RDBMS Minima release di Oracle 10 g , perch le funzioni relative non sono previste per release minori (alter_table_properties)

4.1.2. Tablespace storage management Controllare i parametri di storage del tablespace cui allocato il segmento:

Shrink operations can be performed only on segments in locally managed tablespaces with automatic segment space management (ASSM). Within an ASSM tablespace, all segment types are eligible for online segment shrink except these: IOT mapping tables Tables with rowid based materialized views Tables with function-based indexes

----------------------------------------------esempio-----------------------------------------------------------------------------------SQL> select TABLESPACE_NAME,EXTENT_MANAGEMENt,SEGMENT_SPACE_MANAGEMENT from dba_tablespaces where TABLESPACE_NAME ='PSAPC11';

TABLESPACE_NAME EXTENT_MAN SEGMEN ------------------------------ ---------- -----PSAPC11 LOCAL AUTO

---------------------------------------------fine esempio-------------------------------------------------------------------------------

4.1.3. Verifica sulla struttura del segmento (data type) Le tabelle non devono contenere campi classificati come LONG e LOG RAW : verificare il campo data_type nella tabelle dba_tab_columns . ----------------------------------------------esempio-----------------------------------------------------------------------------------SQL> select DATA_TYPE from dba_tab_columns where TABLE_NAME='ACCTIT' group by DATA_TYPE; DATA_TYPE NUMBER VARCHAR2

---------------------------------------------fine esempio------------------------------------------------------------------------------Vedi approfondimento 2 Attenzione per relase 10.2.0.2 verificare che non vi siano LOB columnns. Infatti in presenza di queste due condizioni lo shrinking segment pu generare corruzione di dati , nota 1021454 Oracle Segment Shrinking may cause LOB corrupt data . Quindi prima di procedere con lo shrink si verifichi che sia implementato il bugfix contenuto nella Note 1021454
SQL> select bugno from v$system_fix_control order by bugno;

Il bug il numero 5636728 e la fix disponibile in SAP Service Marketplace in the Software Center (http://service.sap.com/swcenter-3pmain)

Se non si vuole procedere ad implementare la fix si proceda con la reog online Note 646681 -

Reorganizing tables with BRSPACE


4.1.4. Verifica sul tipo di segmento Si verifichi che non si tratti di un segmento del tipo a) mapping tables and overflow segments of IOTs; si tratta di tabelle che memorizzano i dati secondo i criteri propri di un indice

An IOT keeps its data stored according to the primary key column values for the table. IOTs store the data as if the entire table was stored in an index. A normal index only stores the indexed columns in the index; an IOT stores all of the table's columns in the index. IOTs were new in Oracle8. As the table's data is stored as an index, the rows of the table do not have physical RowIDs. Therefore, you cannot select the RowID pseudocolumn values from an IOT.

----------------------------------------------esempio------------------------------------------------------------------------------------SELECT table_name, tablespace_name, iot_name, iot_type


FROM dba_tables where table_name = 'IOTTEST'

---------------------------------------------fine esempio-------------------------------------------------------------------------------

b) compressed tables; Lopzione attivata da una clausula in fase di creazione delle tabelle, interrogare il campo COMPRESSION nella vista dba_tables .

4.2. Attivit - SQL statments


ALTER TABLE <table_name> ENABLE ROW MOVEMENT; ALTER TABLE <table_name> SHRINK SPACE CASCADE; ALTER TABLE <table_name> DISABLE ROW MOVEMENT;

NB : non utilizzare lopzione COMPACT comporta un temporaneo lock delloggetto, a seconda delle situazioni si valuti luso dellopzione

----------------------------------------------esempio-----------------------------------------------------------------------------------SQL> alter table SAPC11.ACCTCR ENABLE ROW MOVEMENT; Table altered. SQL> alter table SAPC11.ACCTCR SHRINK SPACE CASCADE; Table altered. SQL> alter table SAPC11.ACCTCR DISABLE ROW MOVEMENT;

---------------------------------------------fine esempio-------------------------------------------------------------------------------

4.3. Attivit BT tools


Dalla relase 700 si pu usare anche il BRSPACE funzione tbalter brspace -f tbalter -a shrink brspace -f idalter -a shrink

Potrebbero piacerti anche