Compress table

Scenario: distribuzione di massa di contenuti multimediali e ricchi su Internet, resa possibile attraverso progressi nelle tecnologie a banda larga, contribuisce anche alla crescita del volume di dati complessivo. L’enorme crescita del volume di dati che devono essere conservati online rende l’archiviazione uno dei maggiori elementi di costo della maggior parte dei budget IT

La clausola di compressione può essere specificata a livello di tablespace, tabella o partizione con quanto segue opzioni:

NOCOMPRESS – La tabella o la partizione non è compressa. questa è l’azione predefinita

COMPRESSA: questa opzione è considerata adatta per i sistemi di data warehouse

OMPRESS PER TUTTE LE OPERAZIONI – Questa opzione è considerata adatta per i sistemi OLTP.

Come il nome suggerisce, l’opzione abilita la compressione per tutte le operazioni, comprese le istruzioni DML. In 11gR2 questa opzione ha stato rinominato in COMPRESS FOR OLTP e il nome originale è stato deprecato.

ie for tablespace:
. CREATE TABLESPACE etl_test
DATAFILE ‘/u01/app/oracle/oradata/DB11G/produzione.dbf’
SIZE 100M
DEFAULT COMPRESS FOR ALL OPERATIONS ;
If you want to see option table just query the dictionary view dba_tablespaces as the following statement:
SELECT def_tab_compression, compress_for FROM dba_tablespaces WHERE tablespace_name = ‘etl_test’;
. ALTER TABLESPACE etl_test DEFAULT NOCOMPRESS;
SELECT def_tab_compression, compress_for FROM dba_tablespaces WHERE tablespace_name = ‘etl_test’;
. DROP TABLESPACE etl_test INCLUDING CONTENTS AND DATAFILES;
ie for table:
CREATE TABLE ETL.DWH_CURRENCY
(
dte_yer_mth DATE not null,
cod_curr    VARCHAR2(3) not null,
val_rate    NUMBER,
dsc_curr    VARCHAR2(50)
)
tablespace produzione
compress;
If you want to drop columns from compress table, take action to set UNUSED the column that wants to
drop from table, ie:
ALTER TABLE ETL.DWH_CURRENCY UNUSED (cod_curr);
ALTER TABLE ETL.DWH_CURRENCY DROP unused columns;
If you want to see option table just query the dictionary view user_table as the following statement:
SELECT table_name, compression, compress_for FROM user_tables;
ie for partition:
CREATE TABLE an_customer (
id NUMBER(10),
name VARCHAR2(50),
cod VARCHAR2(20),
dta_in DATE)
TABLESPACE produzione
PARTITION BY RANGE (dta_in) (
PARTITION an_customer1 VALUES LESS THAN (TO_DATE(‘20150101’, ‘YYYYMMDD’)) COMPRESS,
PARTITION an_customer2 VALUES LESS THAN (TO_DATE(‘20150601’, ‘YYYYMMDD’)) COMPRESS FOR ALL
OPERATIONS,
PARTITION an_customer3 VALUES LESS THAN (MAXVALUE) NOCOMPRESS
);
If you want to see option table just query the dictionary view user_tab_partitions as the following
statement:
SELECT table_name, partition_name, compression, compress_for FROM user_tab_partitions;
Around the scenery compress table:
– Compression is not applied to lob segments
– Table compression is only valid for heap organized tables, not index organized tables.
– Table compression cannot be specified for external or clustered tables
Excursus:
– Compression for OLTP
– Compression for File Data
– Compression for Backup Data
– Compression for Network Traffic
http://www.oracle.com/technetwork/database/focus-areas/storage/advanced-compression-whitepaper-130502.pdf

Potrebbero interessarti anche...

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *