11g 计算表在压缩的比率

计算表在压缩的比率


解决方案:


     1)创建一个有相册数据和存储参数的非压缩表与压缩表

     2)确定非压缩表的大小 (DBA_EXTENTS.BYTES)
     
     3)确定压缩表的大小  (DBA_EXTENTS.BYTES)
     
     4) 计算压缩比率

以上测试,表的extent sizes尽量保持小些,以便extents中非使用空间到最小化,以便得到的精准不被扭曲的结果

数据库版本

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production


本测试用全程用SYS用户执行

1.创建一个表空间

SQL>create tablespace test 
    datafile '/u01/app/oracle/oradata/HXZGSJQY/test01.dbf' 
    size 2000m extent management local uniform size 128k;

Tablespace created.


2.创建一个压缩的表

SQL> create table compressed compress tablespace test as select * from dba_source;

Table created.

3.创建一个非压缩的表

SQL>create table non_compressed nocompress tablespace test as select * from dba_source;

Table created.

4计算压缩表COMPRESSED大小

SQL> select sum(bytes) from dba_extents where segment_name = 'COMPRESSED' and owner = 'SYS';

SUM(BYTES)
----------
  58720256

5.计算非压缩表大小

SQL> select sum(bytes) from dba_extents where segment_name = 'NON_COMPRESSED' and owner = 'SYS';

SUM(BYTES)
----------
  88342528

6.计算压缩比率

100 - (( 58720256 /  88342528 ) * 100) = 33.53%  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值