Friday, 8 September 2017

Oracle : Experiment on basic compression on table data

---------Exp start
SQL> select count(1) from scott.xemp;

  COUNT(1)
----------
  14680064

select table_name,COMPRESSION,COMPRESS_FOR from dba_tables where table_name='XEMP';

TABLE_NAME                     COMPRESS COMPRESS_FOR
------------------------------ -------- ------------
XEMP                           DISABLED

SQL> select sum(bytes)/power(1024,2) from dba_segments where segment_name='XEMP';

SUM(BYTES)/POWER(1024,2)
------------------------
                     704


SQL> alter table scott.xemp move compress;

Table altered.

SQL> select sum(bytes)/power(1024,2) from dba_segments where segment_name='XEMP';

SUM(BYTES)/POWER(1024,2)
------------------------
                     176

SQL>  select table_name,COMPRESSION,COMPRESS_FOR from dba_tables where table_name='XEMP';

TABLE_NAME                     COMPRESS COMPRESS_FOR
------------------------------ -------- ------------
XEMP                           ENABLED  BASIC
---------Exp END

Basic compression is free(double check). 

For experiment, table was freshly created with no deletes on the table(i.e. compact). Looks like compression gave about 75% reduction in size. 


This reduces the logical foot print of the table and one may be able to reclaim some space, reduction of file size  is another issue, we may be able to release some space there too(subject to hit and try method).


No comments:

Post a Comment