压缩竹蚂蚁的特性性

【提问】想买把好一些的木刀,有坚木的,压缩竹的;拼版竹的,…_剑道吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0可签7级以上的吧50个
本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:20,398贴子:
【提问】想买把好一些的木刀,有坚木的,压缩竹的;拼版竹的,…
想买把好一些的木刀,有坚木的,压缩竹的;拼版竹的,碳化竹的,哪种好一些,他们有什么特点?求前辈给讲讲。
随后会放制作过程
HELLO,经过将近半个多...
这个档期的电影,给人很...
非常简单的贴。。。 今...
如果你有出色的风采,对...
那个时候的自己呀,上知...
【ID】夏爷一直很低调 ...
阴谋向剧情解析,票根镇楼
【ID】earth夏振清 【地...
个人介绍:混经验混眼熟...
个人介绍:蠢萌蠢萌的女...
日是一个牵...
…………木刀材料没啥区别啊,剑道里木刀就是练习KATA用的,使用频率跟竹剑比……类似于女生的大姨妈吧,一个月一次……有么?一般馆内集中练习都是考段前后或者一个月X次KATA练习安排……预算少,买个坚木的,预算多的买个压缩竹甚至的,不过如果是打算使用木刀,就别买什么这种材料的吧(貌似也没得卖)
一百来块也就够了,拿来稽古都可以,就是比较疼
不锈钢的好,杀伤力大,砍不坏,还可以用来晾衣服
压缩竹的时间长了会崩口子吗?时间长了是不是木质刀性状更稳定些?
看你是怎么练了!原则是木刀是容易断的,建议用竹刀坚韧重量大,当然用竹刀是为了练习型练习切落和转换真剑时为目的,平时还是用38.39号的竹剑就好。
有钱的话,当然弄把名贵点的纯木质的木刀了。什么“压缩竹、拼版竹的木刀”那都是普通货色!神州大地竹子压缩产品遍地都是,不可能做把木刀就成好东西了吧!
压缩竹起毛刺很讨厌的,推荐纯木的,传统,耐用
木质的话较轻,压缩竹会重很多,不过压缩竹会因为气候问题崩刺儿,有时一个不小心就插手上了。我用过压缩竹和枧木的,个人感觉还是枧木的好一些。
贴吧热议榜
使用签名档&&
保存至快速回贴浅析可压缩糖与蔗糖的特性对比_经济论文_管理资料下载网
您的位置: >
> 浅析可压缩糖与蔗糖的特性对比
浅析可压缩糖与蔗糖的特性对比
文章标题:浅析可压缩糖与蔗糖的特性对比摘要:可压缩糖是对蔗糖进行物理改性的非晶形深加工产品,其克服了蔗糖的弱点,保留了蔗糖的色香味,符合现代食品添加剂“天然、安全、环保”要求,在国外已广泛用于食品以及药品的片剂生产。比较了压缩糖与蔗糖的各种特性以及就两者在片剂生产中的基本特性作了简要对比。关键词:可压缩糖;蔗糖;深加工;改性蔗糖是丰富的可再生资源,而可压缩糖是利用蔗糖进行深加工的新产品,是对蔗糖进行物理化学改性,使其不再具有晶形,成为无定形的粉末,克服蔗糖在制片中作片剂(口含片、咀嚼片)的赋型剂时流动性差和硬度大易造成片剂裂片及片重不匀等一些弱点,同时又完全了保留蔗糖固有的甜度与色香味,符合现代食品添加剂和药品赋型剂的。因而作为片剂的赋型剂较之于蔗糖应用更方便,可以不经过制软材、造粒等过程而直接用于压片,减少片剂生产的中间环节,是生产片剂的优良赋型剂和辅料。国外已将两者广泛用于制药与食品行业且都被美国药典所收载,而我国只将蔗糖收入药典,对可压缩糖则了解甚微,经查新检索目前国内无单位研究,无企业生产,无相关标准,还是一片空白,应用也是外资企业从国外带来的配方中使用,目前都要从国外进口。因进口操作手续十分麻烦,2002年我公司受国内外资企业委托,成功地开发出符合美国药典和客户要求的可压缩糖,填补了国内这项空白,我公司研制开发的该产品不仅在委托方已替代了进口产品进行制片,且还出口国外,逐渐被国内外客户所认同。现将可压缩糖和蔗糖的特性进行比较。1可压缩糖(CompressibleSugar)的组成及特性无晶形白色粉末,熔点约168℃,比旋62.6˚,堆积密度约0.630g/ml,能较好地自由流动,可压性强,直接压片用填充剂。主要成分仍为蔗糖(基本式C12O22H11),甜度与蔗糖相当,但溶解速度大于蔗糖,溶解于水中为无色澄清的溶液。美国药典中规定可压缩糖中可以含有淀粉、麦芽糊精、转化糖。国内常将蔗糖与三者之一直接混匀制片,并非熔融共晶为一体,相关书籍上介绍可压缩糖有以下三种类型。1.1蔗糖-糊精共结晶物(Di-Pac&)制法:为97的蔗糖和3糊精的共结晶物。笔者所有公司研发的可压缩糖属这类,即蔗糖和糊精类的熔融共晶体。性状:本品具有较好的流动性,仅在相对湿度大于50以上时才需要加助流剂,其可压性与含水量有密切关系,在含水量为0.3~0.4时可压性迅速增长,至0.4~0.5时达到稳定状态,直到0.8时,失去流动性,并有结块现象。一般来讲,含水量在0.4时对许多药物较为适宜,含水量增大时,仅适宜于制造糖果。本品在贮藏期间,色泽稳定,居所有糖类辅料的首位。其容药量约为25~30,与其他糖类辅料相似。片剂中如含有较多量的Di-Pac时,在贮藏期间硬度有略微增加的倾向。用途:用这类辅料压制的片剂,不易崩解而易溶化,故大都应用于压制咀嚼片,特别是那些不适宜加入甜味剂的片剂。1.2蔗糖-转化糖复合物(Nu-Tab&)制法:为加工过的蔗糖,含有0.4的转化糖(左旋和右旋糖的等分子量混合物),并加有玉蜀黍淀粉及硬脂酸镁各0.1~0.2,两种附加剂主要是有助于压片时粉末的流动而不影响片剂的崩解度。性状:粉粒状,药物的粒度必须相应地与之配合,否则易造成混合不均匀现象。细粉吸湿速度较粗粉快,但在相对湿度80的环境下,两星期后都达到3.3~3.5的相同水平。1.3蔗糖-转化糖聚合物(Sugartab&)性状:为蔗糖产品的聚合体,含有7~10的转化糖,粒度大,与药物混合时,易产生含量不匀问题,应加注意。蔗糖-转化糖聚合物比其他糖类辅料需要更多的润滑剂,一般要常规量的二倍左右的硬脂酸或硬脂酸镁才能达到要求。1.4用途可压缩糖最初被用于制备直接压制咀嚼片,可压缩糖的压片特性受湿度水平微量变化的影响。表Ⅰ是可压缩糖在制片中用量。表Ⅰ可压缩糖在片剂生产中的用途与用量用途浓度片剂处方中的粘合剂(干粘合剂)常规片剂和咀嚼片的填充剂咀嚼片处方中的甜味剂5~1.5禁忌稀酸引起可压缩糖中蔗糖水解成转化糖、碱土金属的氢氧化物与蔗糖反应形成金属派生物(Sucrates)。1.6贮存应贮存于密闭良好的容器中,一般的贮存条件及低的相对湿度下可压缩糖在空气中稳定。2蔗糖粉(SucrosePowder)2.1性状蔗糖是单斜方体晶形,晶形具有光泽,由干燥纯净的蔗糖经加工磨制而成的白色细粉,密度1.15~1.5g/ml,比旋65.9˚,流动性:结晶蔗糖可自由流动;粉末蔗糖为粘性固体。熔点:168~186℃(分解)。2.2用途作为片剂的赋形剂,多数用于口含片和咀嚼片,除作为填充剂外,兼具粘合剂和矫味剂等作用。在一般片剂的处方中,作为结晶型的辅料蔗糖可直接与药物混合进行压片,但蔗糖粉常与淀粉或淀粉糊精按一定适当的比例配合在一起
收藏本文章
下载本文章(DOC格式)
下载本文章(TXT格式)
本页地址:查看: 5709|回复: 25
oracle 数据压缩特性实际应用及优缺点汇总
招聘 : 认证徽章论坛徽章:45
本帖最后由 leonarding 于
06:48 编辑
数据库版本:10.2.0.5.0
引言:“”以前对我来说还是比较新鲜的词,并不是没有听说过,而是没有实际使用过,之前一直做项目经理工作上也设计到数据库的运维,但由于设计的比较充裕,在加上运转的还能让客户接受,所以压缩基本上没怎么用,当时也怕对DML操作有负面影响!之所以现在要这方面的技术,也是因为二期我们的数据量暴增,对机器对性能对运维都用一定的压力和冲击,这也说明了这门技术是在特定环境、特定场合下来使用的,下面我们来详细讲一讲如何去使用这门技术---海量数据之利器“压缩compress”
一、应用场合
答:正如上面所说,压缩技术一般应用在“海量数据”的范畴,在大数据量下并且重复率高的情境下应该的效果才好,适合于OLAP(报表系统)不适合OLTP(在线交易系统),当数据量小时作用还不是很大,只要数据量达到一定程度的时候使用这门技术才有意义。
二、压缩技术的好处
1.节约:我认为压缩技术的最大好处就是节约空间,在存储设备空间很紧张的情况下更需要使用压缩技术来缓解
2.减少memory/IO开销:当使用了压缩技术后,同等记录对应的数据块相对较少,自然而然IO开销就小了
3.提高数据处理效率:原本10个数据块的,经过压缩后变成5个数据块,但还是那些数据,可效率提高了一倍。
三、压缩原理
答:我们都用过rar压缩zip压缩,其实这些压缩的原理都很相似,当然在细微处理上有不同,数据块压缩原理上是使用长度较短符号来代替列中的每个值,由于符号占用空间小于实际值,从而达到节约空间的效果,当列中重复值越多压缩效果越好。
四、数据压缩不适合OLTP系统
1.OLTP是一种多事务短时间片系统,有大量的DML操作,而DML操作我们都知道是有锁lock的(insert&&update&&delete)当数据块中记录数多起来时,导致访问这个数据块的用户就多,就是产生争用和等待,从而降低了效率。
2.数据插入、更新和索引键值更新时,都要先解压缩再更新,等待的时间会更长。
五、分区表的压缩
1.分区表的每个分区都可以独立压缩
2.有些时候,分区表在创建时不设置分区压缩属性,当某个分区需要压缩时,再独立进行压缩
3.如果在表级设置压缩属性的话,那么所有分区都会启动压缩功能,反正如果是某几个分区独立压缩,表级属性上什么也不写的。
leo_partition1 (object_id,object_name)& && & 创建一个六个分区的分区表,没有指定压缩
partition by range (object_id)
partition leo_p1 values less than (1000),
partition leo_p2 values less than (2000),
partition leo_p3 values less than (3000),
partition leo_p4 values less than (4000),
partition leo_p5 values less than (5000),
partition leo_max values less than (maxvalue)
as select object_id,object_name from dba_
& select count(*) from leo_partition1;
&&COUNT(*)
----------
& &&&10351
& select partition_name,compression from user_tab_partitions where table_name='LEO_PARTITION1';
PARTITION_NAME& && && && && &&&COMPRESS
------------------------------ ---------------------
LEO_MAX& && && && && && && & DISABLED
LEO_P1& && && && && && && && & DISABLED
LEO_P2& && && && && && && && & DISABLED
LEO_P3& && && && && && && && & DISABLED
LEO_P4& && && && && && && && & DISABLED
LEO_P5& && && && && && && && & DISABLED
& alter table leo_partition1& && && && && && && && && & 例如 定义表级压缩属性,此时所有分区都压缩
& alter table leo_partition1 modify partition leo_p1& & 我们测试准对leo_p1 和 leo_p5分区进行压缩,来说明分区可以独立压缩
Table altered.
& alter table leo_partition1 modify partition leo_p5
Table altered.
& select partition_name,compression from user_tab_partitions where table_name='LEO_PARTITION1';
PARTITION_NAME& && && && && &&&COMPRESS
------------------------------ -----------------------
LEO_MAX& && && && && && && & DISABLED
LEO_P1& && && && && && && && & ENABLED
LEO_P2& && && && && && && && & DISABLED
LEO_P3& && && && && && && && & DISABLED
LEO_P4& && && && && && && && & DISABLED
LEO_P5& && && && && && && && & ENABLED
6 rows selected.
& alter table leo_partition1 modify partition leo_p5& && &我们还可以取消压缩
Table altered.
& select partition_name,compression from user_tab_partitions where table_name='LEO_PARTITION1';& &leo_p5分区已经取消压缩
PARTITION_NAME& && && && && &&&COMPRESS
------------------------------ -----------------------
LEO_MAX& && && && && && && & DISABLED
LEO_P1& && && && && && && && & ENABLED
LEO_P2& && && && && && && && & DISABLED
LEO_P3& && && && && && && && & DISABLED
LEO_P4& && && && && && && && & DISABLED
LEO_P5& && && && && && && && & DISABLED
六、分区索引的压缩
1.分区表索引中不能对单个独立分区索引设置压缩,要么整体压缩要么不压缩。
2.如果创建分区表索引时未设置压缩,以后都不能在设置了
leo_partition1_index on leo_partition1(object_id)& && && && && & 创建时没有设置压缩
Index created.
& select index_name,compression from user_indexes where table_name='LEO_PARTITION1';& &分区表索引没有压缩
INDEX_NAME& && && && && && && &COMPRESS
------------------------------ -----------------------
LEO_PARTITION1_INDEX& && && &&&DISABLED
& select partition_name,compression from user_ind_partitions where index_name='LEO_PARTITION1_INDEX';& &独立分区索引也没有压缩
PARTITION_NAME& && && && && &&&COMPRESS
------------------------------ -----------------------
LEO_MAX& && && && && && && & DISABLED
LEO_P1& && && && && && && && & DISABLED
LEO_P2& && && && && && && && & DISABLED
LEO_P3& && && && && && && && & DISABLED
LEO_P4& && && && && && && && & DISABLED
LEO_P5& && && && && && && && & DISABLED
& alter index leo_partition1_index rebuild partition leo_p5& && &
alter index leo_partition1_index rebuild partition leo_p5 compress
ERROR at line 1:
ORA-28659: COMPRESS must be specified at object level first& && && && && && && &报错,压缩必须首先在对象级别指定
3.必须创建分区表索引时一次性指定好压缩属性,以后才能对独立分区索引压缩进行修改
& create index leo_partition1_index on leo_partition1(object_id)& && & 创建时指定
Index created.
& select index_name,compression from user_indexes where table_name='LEO_PARTITION1';& &分区表索引已压缩
INDEX_NAME& && && && && && && &COMPRESS
------------------------------ --------
LEO_PARTITION1_INDEX& && && &&&ENABLED
& select partition_name,index_name,compression from user_ind_partitions where index_name='LEO_PARTITION1_INDEX';独立分区索引也压
PARTITION_NAME& && && && && &&&INDEX_NAME& && && && && && && &COMPRESS
------------------------------ ------------------------------ --------
LEO_MAX& && && && && && && & LEO_PARTITION1_INDEX& && && &&&ENABLED
LEO_P1& && && && && && && && & LEO_PARTITION1_INDEX& && && &&&ENABLED
LEO_P2& && && && && && && && & LEO_PARTITION1_INDEX& && && &&&ENABLED
LEO_P3& && && && && && && && & LEO_PARTITION1_INDEX& && && &&&ENABLED
LEO_P4& && && && && && && && & LEO_PARTITION1_INDEX& && && &&&ENABLED
LEO_P5& && && && && && && && & LEO_PARTITION1_INDEX& && && &&&ENABLED
6 rows selected.
& alter index leo_partition1_index rebuild partition leo_p3& && && &独立分区索引取消压缩
Index altered.
& alter index leo_partition1_index rebuild partition leo_p4
Index altered.
& alter index leo_partition1_index rebuild partition leo_p5
Index altered.
& select partition_name,index_name,compression from user_ind_partitions where index_name='LEO_PARTITION1_INDEX';
PARTITION_NAME& && && && && &&&INDEX_NAME& && && && && && && &COMPRESS
------------------------------ ------------------------------ --------
LEO_MAX& && && && && && && & LEO_PARTITION1_INDEX& && && &&&ENABLED
LEO_P1& && && && && && && && & LEO_PARTITION1_INDEX& && && &&&ENABLED
LEO_P2& && && && && && && && & LEO_PARTITION1_INDEX& && && &&&ENABLED
LEO_P3& && && && && && && && & LEO_PARTITION1_INDEX& && && &&&DISABLED
LEO_P4& && && && && && && && & LEO_PARTITION1_INDEX& && && &&&DISABLED
LEO_P5& && && && && && && && & LEO_PARTITION1_INDEX& && && &&&DISABLED
七、数据压缩对空间影响
1.节约空间:数据压缩会节约大量存储空间,我们创建一个压缩表和一个普通表,来对比节约空间的效果
& create table leo_compress_table compress as select * from dba_& && && && &压缩表
Table created.
& create table leo_nocompress_table&&as select * from dba_& && && && && && &普通表
Table created.
& select segment_name,extent_id,bytes from user_extents where segment_name in ('LEO_COMPRESS_TABLE','LEO_NOCOMPRESS_TABLE');
SEGMENT_NAME& && && && &EXTENT_ID& && &BYTES
---------------------- ---------- ----------
LEO_COMPRESS_TABLE& && && && &&&0& && &65536
LEO_COMPRESS_TABLE& && && && &&&1& && &65536
LEO_COMPRESS_TABLE& && && && &&&2& && &65536
LEO_COMPRESS_TABLE& && && && &&&3& && &65536
LEO_COMPRESS_TABLE& && && && &&&4& && &65536
LEO_COMPRESS_TABLE& && && && &&&5& && &65536
LEO_COMPRESS_TABLE& && && && &&&6& && &65536& && &同样数据量,压缩表占用7个区,使用0.43M空间
LEO_NOCOMPRESS_TABLE& && && && &0& && &65536
LEO_NOCOMPRESS_TABLE& && && && &1& && &65536
LEO_NOCOMPRESS_TABLE& && && && &2& && &65536
LEO_NOCOMPRESS_TABLE& && && && &3& && &65536
LEO_NOCOMPRESS_TABLE& && && && &4& && &65536
LEO_NOCOMPRESS_TABLE& && && && &5& && &65536
LEO_NOCOMPRESS_TABLE& && && && &6& && &65536
LEO_NOCOMPRESS_TABLE& && && && &7& && &65536
LEO_NOCOMPRESS_TABLE& && && && &8& && &65536
LEO_NOCOMPRESS_TABLE& && && && &9& && &65536
LEO_NOCOMPRESS_TABLE& && && &&&10& && &65536
LEO_NOCOMPRESS_TABLE& && && &&&11& && &65536
LEO_NOCOMPRESS_TABLE& && && &&&12& && &65536
LEO_NOCOMPRESS_TABLE& && && &&&13& && &65536
LEO_NOCOMPRESS_TABLE& && && &&&14& && &65536
LEO_NOCOMPRESS_TABLE& && && &&&15& && &65536
LEO_NOCOMPRESS_TABLE& && && &&&16& & 1048576& && &同样数据量,普通表占用17个区,使用2M空间
小结:我们可以看出,普通表空间是压缩表空间的4倍多,显然压缩可以节约大量的存储空间,这在磁盘空间不足的情况下很有作用
2.索引压缩比:索引键值重复率越高,压缩比越大,索引键值重复率越低,压缩比越小
我们来比较一下,列中数据重复率的高低对压缩比的影响
& create table leo_compress_table1 as select object_id,object_name from dba_& &&&object_id列没有重复值
Table created.
& create table leo_compress_table2 as select 2 object_id,object_name from dba_& &object_id列全是2,完全重复
Table created.
& create index leo_compress_table1_index on leo_compress_table1 (object_id)& & 为表1创建压缩索引
Index created.
& create index leo_compress_table2_index on leo_compress_table2 (object_id)& & 为表2创建压缩索引
Index created.
& select segment_name,extent_id,bytes from user_extents where segment_name in
('LEO_COMPRESS_TABLE1_INDEX','LEO_COMPRESS_TABLE2_INDEX');
SEGMENT_NAME& && && && && & EXTENT_ID& && &BYTES
-------------------------- ---------- ----------
LEO_COMPRESS_TABLE2_INDEX& && && &&&0& && &65536
LEO_COMPRESS_TABLE2_INDEX& && && &&&1& && &65536
LEO_COMPRESS_TABLE2_INDEX& && && &&&2& && &65536& & 重复率高表2的压缩索引,占用3个区,使用0.18M空间
LEO_COMPRESS_TABLE1_INDEX& && && &&&0& && &65536
LEO_COMPRESS_TABLE1_INDEX& && && &&&1& && &65536
LEO_COMPRESS_TABLE1_INDEX& && && &&&2& && &65536
LEO_COMPRESS_TABLE1_INDEX& && && &&&3& && &65536
LEO_COMPRESS_TABLE1_INDEX& && && &&&4& && &65536& & 重复率低表1的压缩索引,占用5个区,使用0.31M空间
小结:看来索引键值重复率的高低会直接影响压缩索引的存储空间,也从侧面反映了在高重复率的环境下压缩意义才大。
3.那么在索引键值重复率低的情况下,压缩索引与不压缩索引的区别有多大呢,使用show_space()存储过程分析空间使用情况,我列出了show_space()存储过程定义脚本完美版同时支持ASSM and MSSM 段对象存储属性,先要创建show_space()存储过程才能使用,默认是没有的,作者 TOM大叔,有好几个版本,用我这个就可以了,然后重点显示输出结果,否则只显示执行完成但没有结果输出
& create table leo_table1 as select *&&from dba_& && & 表1和表3结构数据完全一致,都是普通表
Table created.
& create table leo_table3 as select *&&from dba_
Table created.
& create index leo_compress_table1_index on leo_table1 (object_id)& & 创建压缩索引,object_id列没有重复值,重复率极低
Index created.
& create index leo_table3_index on leo_table3 (object_id) ;& & 创建普通索引,object_id列没有重复值,重复率极低
Index created.
create or replace procedure show_space& && && && && && && && && && & 定义show_space()存储过程,支持ASSM and MSSM 段对象存储属性
( p_segname in varchar2,
&&p_owner& &in varchar2 default user,
&&p_type& & in varchar2 default 'TABLE',
&&p_partition in varchar2 default NULL )
-- this procedure uses authid current user so it can query DBA_*
-- views using privileges from a ROLE and so it can be installed
-- once per database, instead of once per user that wanted to use it
authid current_user
& & l_free_blks& && && && && &&&
& & l_total_blocks& && && && &&&
& & l_total_bytes& && && && && &
& & l_unused_blocks& && && && &
& & l_unused_bytes& && && && &&&
& & l_LastUsedExtFileId& && && &
& & l_LastUsedExtBlockId& && &&&
& & l_LAST_USED_BLOCK& && && &&&
& & l_segment_space_mgmt& && &&&varchar2(255);
& & l_unformatted_
& & l_unformatted_
& & l_fs1_ l_fs1_
& & l_fs2_ l_fs2_
& & l_fs3_ l_fs3_
& & l_fs4_ l_fs4_
& & l_full_ l_full_
& && &&&-- inline procedure to print out numbers nicely formatted
& && &&&-- with a simple label
& & procedure p( p_label in varchar2, p_num in number )
& && &&&dbms_output.put_line( rpad(p_label,40,'.') ||
& && && && && && && && && && &to_char(p_num,'999,999,999,999') );
& &-- this query is executed dynamically in order to allow this procedure
& &-- to be created by a user who has access to DBA_SEGMENTS/TABLESPACES
& &-- via a role as is customary.
& &-- NOTE: at runtime, the invoker MUST have access to these two
& &-- views!
& &-- this query determines if the object is a ASSM object or not
& && &execute immediate
& && && & 'select ts.segment_space_management
& && && && & from dba_segments seg, dba_tablespaces ts
& && && && &where seg.segment_name& && &= _segname
& && && && &&&and (_partition is null or
& && && && && && &seg.partition_name = _partition)
& && && && &&&and seg.owner = _owner
& && && && &&&and seg.tablespace_name = ts.tablespace_name'
& && && && & into l_segment_space_mgmt
& && && && &using p_segname, p_partition, p_partition, p_
& &exception
& && & when too_many_rows then
& && && & dbms_output.put_line
& && && & ( 'This must be a partitioned table, use p_partition =& ');
& &-- if the object is in an ASSM tablespace, we must use this API
& &-- call to get space information, else we use the FREE_BLOCKS
& &-- API for the user managed segments
& &if l_segment_space_mgmt = 'AUTO'
& &&&dbms_space.space_usage
& &&&( p_owner, p_segname, p_type, l_unformatted_blocks,
& && & l_unformatted_bytes, l_fs1_blocks, l_fs1_bytes,
& && & l_fs2_blocks, l_fs2_bytes, l_fs3_blocks, l_fs3_bytes,
& && & l_fs4_blocks, l_fs4_bytes, l_full_blocks, l_full_bytes, p_partition);
& &&&p( 'Unformatted Blocks ', l_unformatted_blocks );
& &&&p( 'FS1 Blocks (0-25)&&', l_fs1_blocks );
& &&&p( 'FS2 Blocks (25-50) ', l_fs2_blocks );
& &&&p( 'FS3 Blocks (50-75) ', l_fs3_blocks );
& &&&p( 'FS4 Blocks (75-100)', l_fs4_blocks );
& &&&p( 'Full Blocks& && &&&', l_full_blocks );
& &&&dbms_space.free_blocks(
& && & segment_owner& &&&=& p_owner,
& && & segment_name& && &=& p_segname,
& && & segment_type& && &=& p_type,
& && & freelist_group_id =& 0,
& && & free_blks& && && &=& l_free_blks);
& &&&p( 'Free Blocks', l_free_blks );
&&-- and then the unused space API call to get the rest of the
&&-- information
&&dbms_space.unused_space
&&( segment_owner& &&&=& p_owner,
& & segment_name& && &=& p_segname,
& & segment_type& && &=& p_type,
& & partition_name& & =& p_partition,
& & total_blocks& && &=& l_total_blocks,
& & total_bytes& && & =& l_total_bytes,
& & unused_blocks& &&&=& l_unused_blocks,
& & unused_bytes& && &=& l_unused_bytes,
& & LAST_USED_EXTENT_FILE_ID =& l_LastUsedExtFileId,
& & LAST_USED_EXTENT_BLOCK_ID =& l_LastUsedExtBlockId,
& & LAST_USED_BLOCK =& l_LAST_USED_BLOCK );
& & p( 'Total Blocks', l_total_blocks );
& & p( 'Total Bytes', l_total_bytes );
& & p( 'Total MBytes', trunc(l_total_bytes/) );
& & p( 'Unused Blocks', l_unused_blocks );
& & p( 'Unused Bytes', l_unused_bytes );
& & p( 'Last Used Ext FileId', l_LastUsedExtFileId );
& & p( 'Last Used Ext BlockId', l_LastUsedExtBlockId );
& & p( 'Last Used Block', l_LAST_USED_BLOCK );
Procedure created.
&& && && && && && && && && && && & 必须设置输出show_space()存储过程结果,否则只显示执行完成但没有结果输出
& execute show_space('LEO_COMPRESS_TABLE1_INDEX',USER,'INDEX');& & 压缩索引leo_compress_table1_index空间使用情况
Unformatted Blocks .....................& && && && && &0
FS1 Blocks (0-25)&&.....................& && && && && &&&0
FS2 Blocks (25-50) .....................& && && && && & 1
FS3 Blocks (50-75) .....................& && && && && & 0
FS4 Blocks (75-100).....................& && && && && &0
Full Blocks& && &&&.....................& && && && && && && & 31& && && && && &&&其中用了31个
Total Blocks............................& && && && && && &&&40& && && && && &&&占用了40个数据块
Total Bytes.............................& && && && && && &&&327,680& && && && && &&&0.31M
Total MBytes............................& && && && && && &0
Unused Blocks...........................& && && && && & 3
Unused Bytes............................& && && && && & 24,576
Last Used Ext FileId....................& && && && && &7
Last Used Ext BlockId...................& && && && & 4,569
Last Used Block.........................& && && && && & 5
PL/SQL procedure successfully completed.
& execute show_space('LEO_TABLE3_INDEX',USER,'INDEX');& && && && & 普通索引leo_table3_index空间使用情况
Unformatted Blocks .....................& && && && && &0
FS1 Blocks (0-25)&&.....................& && && && && &&&0
FS2 Blocks (25-50) .....................& && && && && & 1
FS3 Blocks (50-75) .....................& && && && && & 0
FS4 Blocks (75-100).....................& && && && && &0
Full Blocks& && &&&.....................& && && && && && && & 22& && && && && &&&其中用了22个
Total Blocks............................& && && && && && &&&32& && && && && &&&占用了32个数据块
Total Bytes.............................& && && && && && &&&262,144& && && && && &&&0.25M
Total MBytes............................& && && && && && &0
Unused Blocks...........................& && && && && & 5
Unused Bytes............................& && && && && &40,960
Last Used Ext FileId....................& && && && && &7
Last Used Ext BlockId...................& && && && &4,601
Last Used Block.........................& && && && && &3
PL/SQL procedure successfully completed.
小结:那么在索引键值重复率低的情况下,压缩索引比普通索引占用的空间还多,这是为什么呢,压缩原理就是把键值用符号代替,重复键值越多冗余空间越多,但我们测试键值几乎是没有重复的,还要腾出额外空间给映射列表(键值:符号对应表),所以压缩索引使用的空间就会更多。
八、数据压缩对性能影响
原因:数据压缩后,扫描数据块变少了,导致逻辑I/O(LIO)减少(一致性读减少),同时有更多的数据块缓存到内存中,导致物理I/O(PIO)减少,当然CPU消耗自然也少了。
1.海量数据普通表和海量数据压缩表空间比较
& create table leo_big_table as select *&&from dba_& && && && && && && && &海量数据普通表,16万条记录
Table created.
& insert into leo_big_table select * from leo_big_
10374 rows created.
20748 rows created.
41496 rows created.
82992 rows created.
& select count(*) from leo_big_
&&COUNT(*)
----------
& & 165984
Commit complete.
& create table leo_big_table_compress compress&&as select *&&from dba_& &&&海量数据压缩表,16万条记录
Table created.
& insert into leo_big_table_compress select * from leo_big_table_
10375 rows created.
20750 rows created.
41500 rows created.
83000 rows created.
& select count(*) from leo_big_table_
&&COUNT(*)
----------
& & 166000
Commit complete.
& execute show_space('LEO_BIG_TABLE');& && && && && && && & 海量数据普通表,16万条记录
Unformatted Blocks .....................& && && && && &0
FS1 Blocks (0-25)&&.....................& && && && && &&&1
FS2 Blocks (25-50) .....................& && && && && & 0
FS3 Blocks (50-75) .....................& && && && && & 0
FS4 Blocks (75-100).....................& && && && && &5
Full Blocks& && &&&.....................& && && && && && && &&&2,064& && && & 其中2064个装满了数据
Total Blocks............................& && && && && && && &2,176& && && & 占用了2176个数据块
Total Bytes.............................& && && && && && && &17,825,792
Total MBytes............................& && && && && && &&&17& && && & 17M空间
Unused Blocks...........................& && && && && && &64
Unused Bytes............................& && && && && && &524,288
Last Used Ext FileId....................& && && && && &&&7
Last Used Ext BlockId...................& && && && &&&6,793
Last Used Block.........................& && && && && &&&64
PL/SQL procedure successfully completed.
& execute show_space('LEO_BIG_TABLE_COMPRESS');& && && && & 海量数据压缩表,16万条记录
Unformatted Blocks .....................& && && && && &0
FS1 Blocks (0-25)&&.....................& && && && && &&&0
FS2 Blocks (25-50) .....................& && && && && & 0
FS3 Blocks (50-75) .....................& && && && && & 1
FS4 Blocks (75-100).....................& && && && &&&31
Full Blocks& && &&&.....................& && && && && && && &1,786& && && & 其中1786个装满了数据
Total Blocks............................& && && && && && & 1,920& && && & 占用了1920个数据块
Total Bytes.............................& && && && && && & 15,728,640
Total MBytes............................& && && && && &&&15& && && & 15M空间
Unused Blocks...........................& && && && && & 64
Unused Bytes............................& && && && && & 524,288
Last Used Ext FileId....................& && && && && & 7
Last Used Ext BlockId...................& && && && & 8,713
Last Used Block.........................& && && && && & 64
PL/SQL procedure successfully completed.
小结:显而易见,海量数据的环境下,压缩表比普通表占用的空间更少
2.10046事件追踪查询select普通表和压缩表的执行计划(全表扫描)
& alter session set events '10046 trace name context forever,level 12';
& select * from leo_big_
165984 rows selected.
& select * from leo_big_table_
166000 rows selected.
tkprof leo_ora_1983.trc leo_.txt sys=no
more leo_.txt
select * from leo_big_table& && && && && && && && && && && && && && && && && && && && &普通表sql性能指标
call& &&&count& && & cpu& & elapsed 磁盘读disk& && &query& & current& && &&&rows
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
Parse& && &&&1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && & 硬解析
Execute& & 1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && & 执行
Fetch&&11067& && &1.55& && & 1.44& && && & 0& && &13000& && && & 0& && &165984& && & 取操作
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
total& & 11069& && &1.55& && & 1.44& && && & 0& && &13000& && && & 0& && &165984
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 27
Rows& &&&Row Source Operation
-------&&-----------------------------------------------------------------------
165984&&TABLE ACCESS FULL LEO_BIG_TABLE (cr=13000 pr=0 pw=0 time=1992805 us)& && && & 输出165984行,一致性读13000
********************************************************************************
select * from leo_big_table_compress& && && && && && && && && && && && && && && && && &压缩表sql性能指标
call& &&&count& && & cpu& & elapsed 磁盘读disk& && &query& & current& && &&&rows
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
Parse& && &&&1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && & 硬解析
Execute& & 1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && & 执行
Fetch&&11068& && &1.14& && & 1.13& && && & 0& && &12775& && && & 0& && &166000& && & 取操作
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
total& & 11070& && &1.14& && & 1.13& && && & 0& && &12775& && && & 0& && &166000
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 27
Rows& &&&Row Source Operation
-------&&---------------------------------------------------
166000&&TABLE ACCESS FULL LEO_BIG_TABLE_COMPRESS (cr=12775 pr=0 pw=0 time=1495219 us)&&输出166000行,一致性读12775
********************************************************************************
小结:这里磁盘读disk都是0是因为所有记录都缓存在内存中,从一致性读、CPU、elapsed等指标上看,压缩表还是优于普通表
3.10046事件追踪查询select普通表和压缩表的sql执行计划(走索引)
& create index leo_big_table_index on leo_big_table(object_id);& && && && && && && &&&普通表创建索引
Index created.
& create index leo_big_table__compress_index on leo_big_table_compress(object_id);& & 压缩表创建索引
Index created.
& select * from leo_big_table where object_id=5276;& && && && && && && && && && && &
& select * from leo_big_table_compress where object_id=5276;& && && && && && && && &
select * from leo_big_table where object_id=5276& && && && && && && && && && && && && && &&&普通表走索引检索sql性能指标
call& &&&count& && & cpu& & elapsed 磁盘读disk& && &query& & current& && &&&rows
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
Parse& && &&&1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && && && &硬解析
Execute& & 1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && && && &执行
Fetch& && &&&3& && &0.00& && & 0.00& && && & 0& && && &20& && && & 0& && && & 16& && && && &取操作
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
total& && &&&5& && &0.00& && & 0.00& && && & 0& && && &20& && && & 0& && && & 16
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 27
Rows& &&&Row Source Operation
-------&&---------------------------------------------------
& &&&16&&TABLE ACCESS BY INDEX ROWID LEO_BIG_TABLE (cr=20 pr=0 pw=0 time=316 us)& && && && & 输出16行,走索引,表一致性读20
& &&&16& &INDEX RANGE SCAN LEO_BIG_TABLE_INDEX (cr=4 pr=0 pw=0 time=169 us)(object id 11066) 因为索引没压缩,索引一致性读4
********************************************************************************
select * from leo_big_table_compress where object_id=5276& && && && && && && && && && && &&&压缩表走索引检索sql性能指标
call& &&&count& && & cpu& & elapsed 磁盘读disk& && &query& & current& && &&&rows
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
Parse& && &&&1& && &0.00& && & 0.00& && && & 0& && && & 2& && && & 0& && && &&&0& && && && &硬解析
Execute& & 1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && && && &执行
Fetch& && &&&3& && &0.00& && & 0.00& && && & 0& && && &20& && && & 0& && && & 16& && && && &取操作
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
total& && &&&5& && &0.00& && & 0.00& && && & 0& && && &22& && && & 0& && && & 16
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 27
Rows& &&&Row Source Operation
-------&&---------------------------------------------------
& &&&16&&TABLE ACCESS BY INDEX ROWID LEO_BIG_TABLE_COMPRESS (cr=20 pr=0 pw=0 time=140 us)& &&&输出16行,走索引,一致性读22
& &&&16& &INDEX RANGE SCAN LEO_BIG_TABLE__COMPRESS_INDEX (cr=4 pr=0 pw=0 time=31 us)(object id 11067) 因为索引没压缩,索引一致性读4
********************************************************************************
小结:我们看到压缩表比普通表的一致性读要多2个,原因有二,第一 查询的数据太少,不容易看出来。第二 先解压再显示,解压需要额外的开销。在海量数据环境下,压缩表走索引的效果应该比普通表要好。
4.10046事件追踪order by group by普通表和压缩表的sql执行计划
select * from leo_big_table order by owner& && && && && && && && && && && && && && && &&&普通表order by 性能指标
call& &&&count& && & cpu& & elapsed 磁盘读disk& && &query& & current& && &&&rows
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
Parse& && &&&1& && &0.00& && & 0.00& && && & 0& && && & 1& && && & 0& && && &&&0& && && &硬解析
Execute& & 1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && && &执行
Fetch& & 11067& && &2.91& && &13.21& && & 2116& && & 2087& && && &28& && &165984& && && &取操作
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
total& & 11069& && &2.91& && &13.21& && & 2116& && & 2088& && && &28& && &165984
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 27
Rows& &&&Row Source Operation
-------&&---------------------------------------------------
165984&&SORT ORDER BY (cr=2087 pr=2116 pw=2116 time= us)& && && && && & 全表扫描排序后输出165984行,一致性读2087,磁盘读2116
165984& &TABLE ACCESS FULL LEO_BIG_TABLE (cr=2076 pr=0 pw=0 time=7635325 us)
********************************************************************************
select * from leo_big_table_compress order by owner& && && && && && && && && && && && && &压缩表order by 性能指标
call& &&&count& && & cpu& & elapsed 磁盘读disk& && &query& & current& && &&&rows
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
Parse& && &&&1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && && & 硬解析
Execute& & 1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && && & 执行
Fetch& & 11068& && &1.65& && & 2.16& && & 2117& && & 1834& && && & 4& && &166000& && && & 取操作
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
total& & 11070& && &1.65& && & 2.17& && & 2117& && & 1834& && && & 4& && &166000
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 27
Rows& &&&Row Source Operation
-------&&---------------------------------------------------
166000&&SORT ORDER BY (cr=1834 pr=2117 pw=2117 time=2356632 us)& && && && && && &全表扫描排序后输出166000行,一致性读1834,磁盘读2117
166000& &TABLE ACCESS FULL LEO_BIG_TABLE_COMPRESS (cr=1823 pr=0 pw=0 time=1494518 us)
********************************************************************************
select owner,count(*) from leo_big_table group by owner& && && && && && && && && && && && &普通表group by 性能指标
call& &&&count& && & cpu& & elapsed 磁盘读disk& && &query& & current& && &&&rows
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
Parse& && &&&1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && && &&&硬解析
Execute& & 1& && &0.00& && & 0.00& && && & 0& && && &15& && && & 0& && && &&&0& && && &&&执行
Fetch& && &&&2& && &0.10& && & 0.10& && && & 0& && & 2076& && && & 0& && && &&&9& && && &&&取操作
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
total& && &&&4& && &0.10& && & 0.10& && && & 0& && & 2091& && && & 0& && && &&&9
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 27
Rows& &&&Row Source Operation
-------&&---------------------------------------------------
& && &9&&HASH GROUP BY (cr=2091 pr=0 pw=0 time=116605 us)& && && && && && && && &分组计算后输出9行,一致性读2091
165984& &TABLE ACCESS FULL LEO_BIG_TABLE (cr=2076 pr=0 pw=0 time=1825987 us)& & 全表扫描165984行
********************************************************************************
select owner,count(*) from leo_big_table_compress group by owner& && && && && && && && && & 压缩表group by 性能指标
call& &&&count& && & cpu& & elapsed 磁盘读disk& && &query& & current& && &&&rows
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
Parse& && &&&1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && && && &硬解析
Execute& & 1& && &0.00& && & 0.00& && && & 0& && && & 0& && && & 0& && && &&&0& && && && &执行
Fetch& && &&&2& && &0.08& && & 0.08& && && & 0& && & 1823& && && & 0& && && &&&9& && && && &取操作
------- ------&&-------- ---------- ---------- ---------- ----------&&----------
total& && &&&4& && &0.08& && & 0.08& && && & 0& && & 1823& && && & 0& && && &&&9
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 27
Rows& &&&Row Source Operation
-------&&---------------------------------------------------
& && &9&&HASH GROUP BY (cr=1838 pr=0 pw=0 time=94680 us)& && && && && && && && && &分组计算后输出9行,一致性读1838
166000& &TABLE ACCESS FULL LEO_BIG_TABLE_COMPRESS (cr=1823 pr=0 pw=0 time=1162061 us)&&全表扫描166000行
小结:从上面测试结果来看,压缩表的性能更好一些,尤其在逻辑读I/O(LIO)、一致性读、物理读I/O(PIO)、CPU等指标上。
招聘 : 认证徽章论坛徽章:45
九、数据压缩和DML操作
答:不管从实际应用还是官方说明,“压缩”技术都是属于OLAP数据仓库领域
问:那么在OLTP领域就不能使用“压缩”技术了嘛? 其实不然,特定场合DML操作可以压缩处理的,但大部分是不作压缩的
(1)alter table 表名 move compress& && && &&&给普通表进行压缩,通过MOVE方式进行数据重组
(2)alter table 表名 move partition 分区名 compress&&给分区表进行压缩,每个分区都可以独立压缩,结尾必须添加compress关键字否则不做压缩
(3)create table 表名 compress as select& &&&CTAS&&对象属性
(4)insert /*+ append */& && && && && && &&&直接加载插入数据,必压缩。 常规 insert into 不压缩数据
(5)sqlldr 参数 direct path& && && && && && &sqlload 直接路径加载,必压缩
实验 1& &CTAS
LS@LEO& create table leo_test1 compress as select * from dba_& && && && && & CTAS 创建初就压缩
Table created.
LS@LEO& create table leo_test2 compress as select * from dba_objects where 1=2;& && &只要结构不要数据
Table created.
LS@LEO& select count(*) from leo_test1;& && && && && && && && && && && && && && && & 有10378行
&&COUNT(*)
----------
& &&&10378
LS@LEO& select count(*) from leo_test2;& && && && && && && && && && && && && && && & 只要结构不要数据 successful
&&COUNT(*)
----------
& && && &0
LS@LEO& insert into leo_test2 select * from dba_& && && && && && && && && &&&常规insert&&into&&不压缩数据
10379 rows created.
LS@LEO&& && && && && && && && && && && && && && && && && && && && && && && & 提交
LS@LEO&& && && && && && && && && && && && && && && && && && && &打开屏幕输出
LS@LEO& execute show_space('LEO_TEST1');& && && && && && && && && && && && && && &&&使用CTAS直接压缩
Unformatted Blocks .....................& && && && && &0
FS1 Blocks (0-25)&&.....................& && && && && &&&0
FS2 Blocks (25-50) .....................& && && && && & 0
FS3 Blocks (50-75) .....................& && && && && & 0
FS4 Blocks (75-100).....................& && && && && &0
Full Blocks& && &&&.....................& && && && && && && &&&45& && && && && && && && && & 其中用了45个装满数据
Total Blocks............................& && && && && && && &56& && && && && && && && && & 占用了56个数据块
Total Bytes.............................& && && && && && && &458,752& && && && && && && && && & 0.43M空间,已压缩
Total MBytes............................& && && && && && & 0& && && && && && && && && && &
Unused Blocks...........................& && && && && && &5
Unused Bytes............................& && && && && && &40,960
Last Used Ext FileId....................& && && && && && &7
Last Used Ext BlockId...................& && && && && & 9,649
Last Used Block.........................& && && && && && & 3
PL/SQL procedure successfully completed.
LS@LEO& execute show_space('LEO_TEST2');& && && && && && && && && && && && && && & 常规insert into 不压缩数据
Unformatted Blocks .....................& && && && && &0
FS1 Blocks (0-25)&&.....................& && && && && &&&1
FS2 Blocks (25-50) .....................& && && && && & 0
FS3 Blocks (50-75) .....................& && && && && & 0
FS4 Blocks (75-100).....................& && && && && &2
Full Blocks& && &&&.....................& && && && && && && & 115& && && && && && && && && & 其中用了115个装满数据
Total Blocks............................& && && && && && &&&128& && && && && && && && && & 占用了128个数据块
Total Bytes.............................& && && && && && &&&1,048,576
Total MBytes............................& && && && && && &1& && && && && && && && && & 1M空间
Unused Blocks...........................& && && && && &&&0
Unused Bytes............................& && && && && &&&0
Last Used Ext FileId....................& && && && && &&&7
Last Used Ext BlockId...................& && && && &&&9,777
Last Used Block.........................& && && && && &&&8
PL/SQL procedure successfully completed.
小结:我们看到leo_test2表比leo_test1表占用的空间几乎多了一倍,为什么都用CTAS创建的表空间会不一样呢,leo_test2表在创建时只有结构没有数据,压缩只针对数据压缩因此没有数据就没有压缩。后来我们使用了常规insert into 插入数据但数据是不压缩的,这是导致表2比表1占用空间多的原因。
实验 2& &insert /*+ append */& && && && && &直接加载插入数据,必压缩
LS@LEO& truncate table leo_test2;& && && && && && && && && && && && && && && && && &清空leo_test2表
Table truncated.
LS@LEO& insert /*+ append */ into leo_test2 select * from dba_& && && && &&&直接加载插入数据必压缩
10379 rows created.
LS@LEO&& && && && && && && && && && && && && && && && && && && && && && && &提交
LS@LEO& execute show_space('LEO_TEST2');& && && && && && && && && && && && && && &&&分析空间使用情况
Unformatted Blocks .....................& && && && && &0
FS1 Blocks (0-25)&&.....................& && && && && &&&0
FS2 Blocks (25-50) .....................& && && && && & 0
FS3 Blocks (50-75) .....................& && && && && & 0
FS4 Blocks (75-100).....................& && && && && &0
Full Blocks& && &&&.....................& && && && && && && & 45& && && && && && && && && & 其中用了45个装满数据
Total Blocks............................& && && && && && &&&56& && && && && && && && && & 占用了56个数据块
Total Bytes.............................& && && && && && &&&458,752& && && && && && && && && & 0.43M空间,已压缩
Total MBytes............................& && && && && && &0
Unused Blocks...........................& && && && && & 5
Unused Bytes............................& && && && && & 40,960
Last Used Ext FileId....................& && && && && &7
Last Used Ext BlockId...................& && && && &9,705
Last Used Block.........................& && && && && &3
小结:使用insert /*+ append */ 直接加载插入数据方式,数据必须压缩状态
实验 3& &update操作对压缩数据作解压缩处理,空间立刻恢复为未压缩时的容量
LS@LEO& update leo_test1 set object_name=object_name||'leo_nocompress';& && && &leo_test1已经是压缩状态,现在对其进行update操作
10378 rows updated.
Commit complete.
LS@LEO& execute show_space('LEO_TEST1');& && && && && && && && && && && && && & update操作对压缩数据进行解压缩处理
Unformatted Blocks .....................& && && && && &0
FS1 Blocks (0-25)&&.....................& && && && && &&&0
FS2 Blocks (25-50) .....................& && && && && & 1
FS3 Blocks (50-75) .....................& && && && && & 0
FS4 Blocks (75-100).....................& && && && &&&36
Full Blocks& && &&&.....................& && && && && && && & 143& && && && && && && && &其中用了143个装满数据
Total Blocks............................& && && && && && &&&256& && && && && && && && &占用了256个数据块
Total Bytes.............................& && && && && && &&&2,097,152
Total MBytes............................& && && && && && &2& && && && && && && && &2M空间,已经解压缩了,空间恢复为未压缩是的容量
Unused Blocks...........................& && && && && &&&64
Unused Bytes............................& && && && && &&&524,288
Last Used Ext FileId....................& && && && && &&&7
Last Used Ext BlockId...................& && && && &&&9,865
Last Used Block.........................& && && && && &&&64
PL/SQL procedure successfully completed.
小结:此时leo_test1表的空间立刻恢复为未压缩时的容量,但比原来的空间还要大呢,是因为update操作将记录的长度变大了,空间自然也变大了!
实验 4& &给普通表进行压缩,通过MOVE方式进行数据重组
LS@LEO& alter table leo_test1& && && && && && && && && && && &&&现在对普通表进行压缩重组数据
Table altered.
LS@LEO& execute show_space('LEO_TEST1');
Unformatted Blocks .....................& && && && && &0
FS1 Blocks (0-25)&&.....................& && && && && &&&0
FS2 Blocks (25-50) .....................& && && && && & 0
FS3 Blocks (50-75) .....................& && && && && & 0
FS4 Blocks (75-100).....................& && && && && &0
Full Blocks& && &&&.....................& && && && && && && &&&65& && && && && && && &&&其中用了65个装满数据
Total Blocks............................& && && && && && && &72& && && && && && && &&&占用了72个数据块
Total Bytes.............................& && && && && && && &589,824& && && && && && && &&&0.56M空间,已经压缩
Total MBytes............................& && && && && && & 0
Unused Blocks...........................& && && && && &&&0
Unused Bytes............................& && && && && &&&0
Last Used Ext FileId....................& && && && && &&&7
Last Used Ext BlockId...................& && && && &&&9,849
Last Used Block.........................& && && && && &&&8
PL/SQL procedure successfully completed.
小结:同样的数据经过重组数据进行压缩,可以比未压缩时节约了4倍空间,在一些特定场合使用压缩技术还是非常有效果的。
实验 5& &给分区表进行压缩,每个分区都可以独立压缩
LS@LEO& create table leo_test_partition1 (object_id,object_name)& && && && & 我们先创建一个分区表,共6个分区
partition by range (object_id)
partition leo_p1 values less than (1000),
partition leo_p2 values less than (2000),
partition leo_p3 values less than (3000),
partition leo_p4 values less than (4000),
partition leo_p5 values less than (5000),
partition leo_max values less than (maxvalue)
as select object_id,object_name from dba_
Table created.
LS@LEO& insert into leo_test_partition1 select * from leo_test_partition1;& & 多次加载数据
LS@LEO& select count(*) from leo_test_partition1;& && && && && && && && && &&&33万行
&&COUNT(*)
----------
& & 332576
LS@LEO& select count(*) from leo_test_partition1 partition (leo_p2);& && && & leo_p2分区有32000行
&&COUNT(*)
----------
& &&&32000
LS@LEO&& && && && && && && && && && && && && && && && && && && && && &提交
LS@LEO& select partition_name,compression from user_tab_partitions where table_name='LEO_TEST_PARTITION1';& &6个分区都是未压缩状态
PARTITION_NAME& && && && && &&&COMPRESS
------------------------------ -------- --------
LEO_MAX& && && && && && && &&&DISABLED
LEO_P1& && && && && && && && & DISABLED
LEO_P2& && && && && && && && & DISABLED
LEO_P3& && && && && && && && & DISABLED
LEO_P4& && && && && && && && & DISABLED
LEO_P5& && && && && && && && & DISABLED
LS@LEO& execute show_space('LEO_TEST_PARTITION1',USER,'TABLE PARTITION','LEO_P2');& && &&&leo_p2分区未压缩时空间情况
Unformatted Blocks .....................& && && && && &0
FS1 Blocks (0-25)&&.....................& && && && && &&&0
FS2 Blocks (25-50) .....................& && && && && & 0
FS3 Blocks (50-75) .....................& && && && && & 0
FS4 Blocks (75-100).....................& && && && && &5
Full Blocks& && &&&.....................& && && && && && && & 105& && && && && && && && && && && & 其中用了105个装满数据
Total Blocks............................& && && && && && &&&120& && && && && && && && && && && & 占用了120个数据块
Total Bytes.............................& && && && && && &&&983,040& && && && && && && && && && && & 0.9375M
Total MBytes............................& && && && && && & 0
Unused Blocks...........................& && && && && &&&0
Unused Bytes............................& && && && && &&&0
Last Used Ext FileId....................& && && && && &&&7
Last Used Ext BlockId...................& && && && &&&10,601
Last Used Block.........................& && && && && &&&8
PL/SQL procedure successfully completed.
LS@LEO& alter table leo_test_partition1 move partition leo_p2 单独对leo_p2分区进行压缩,结尾必须添加compress关键字否则不做压缩
Table altered.
LS@LEO& select partition_name,compression from user_tab_partitions where table_name='LEO_TEST_PARTITION1';&&leo_p2分区已经压缩
PARTITION_NAME& && && && && &&&COMPRESS
------------------------------ --------
LEO_MAX& && && && && && && &&&DISABLED
LEO_P1& && && && && && && && & DISABLED
LEO_P2& && && && && && && && & ENABLED
LEO_P3& && && && && && && && & DISABLED
LEO_P4& && && && && && && && & DISABLED
LEO_P5& && && && && && && && & DISABLED
LS@LEO& execute show_space('LEO_TEST_PARTITION1',USER,'TABLE PARTITION','LEO_P2');& && && &leo_p2分区是压缩时空间情况
Unformatted Blocks .....................& && && && && &0
FS1 Blocks (0-25)&&.....................& && && && && &&&0
FS2 Blocks (25-50) .....................& && && && && & 0
FS3 Blocks (50-75) .....................& && && && && & 0
FS4 Blocks (75-100).....................& && && && && &0
Full Blocks& && &&&.....................& && && && && && && & 104& && && && && && && && && && && &&&其中用了104个装满数据,只比原来少了1个块
Total Blocks............................& && && && && && &&&120& && && && && && && && && && && &&&占用了120个数据块
Total Bytes.............................& && && && && && &&&983,040
Total MBytes............................& && && && && && &0
Unused Blocks...........................& && && && && &&&6
Unused Bytes............................& && && && && & 49,152
Last Used Ext FileId....................& && && && && &7
Last Used Ext BlockId...................& && && && & 11,297
Last Used Block.........................& && && && && &&&2
PL/SQL procedure successfully completed.
小结:我们看到leo_p2分区压缩时比未压缩时只在使用的数据块上少了一个,感觉基本上没怎么压,后来分析数据发现,记录重复率非常小,样本数据条数也不够大,导致压缩比也小,效果稍差。
原理出处:表压缩比:列中数据重复率越高,压缩比越大,列中数据重复率越低,压缩比越小
大家在做测试的时候可以和我的结果对比一下,看看是不是一样,如果分析的不足,请提出宝贵意见,共同进步:)
十、数据压缩应用场景
1.静态数据:这种数据处在不在改变的状态,只用于查询和分析,可以压缩
2.历史数据:这种数据当前已经不在使用,只用于以后归档查询,可以压缩
3.海量数据:提高数据处理效率,减少内存和磁盘I/O开销,可以压缩
4.备份数据:压缩备份可以节约大量空间给其他对象使用,可以压缩
Leonarding
天津&summer
分享技术~收获快乐
招聘 : 认证徽章论坛徽章:45
认证徽章论坛徽章:67
赞一下总结。
不过这个还是要标注下数据库版本的,11G的压缩技术得到了长足的进步。
另外,数据是否有序对压缩表的影响也很大
招聘 : 认证徽章论坛徽章:45
kelsoncong 发表于
赞一下总结。
不过这个还是要标注下数据库版本的,11G的压缩技术得到了长足的进步。
另外,数据是否有序对 ...
数据库版本:10.2.0.5.0
hello 虫虫 版主&&数据库版本已经添加&&好了& & 多谢关注,加个精呗 更多谢
论坛徽章:376
认证徽章论坛徽章:67
leonarding 发表于
数据库版本:10.2.0.5.0
hello 虫虫 版主&&数据库版本已经添加&&好了& & 多谢关注,加个精呗 更多谢
福哥已经出手做过分类了,能不能射精,还要等福哥的定夺
招聘 : 认证徽章论坛徽章:45
〇〇 发表于
OO&&我花了 好几天 写&&才发现&&帖子 最长 只有 50000字节
招聘 : 认证徽章论坛徽章:45
kelsoncong 发表于
福哥已经出手做过分类了,能不能射精,还要等福哥的定夺
哈& &fuge&&fuge&&召唤& &好的& &fuge是大师&&跟着大师走 吃喝全都有
认证徽章论坛徽章:24
支持一下。。嘿嘿。加油哦
itpub.net All Right Reserved. 北京皓辰网域网络信息技术有限公司版权所有    
 北京市公安局海淀分局网监中心备案编号: 广播电视节目制作经营许可证:编号(京)字第1149号

我要回帖

更多关于 蚂蚁的特性 的文章

 

随机推荐