HCC compression on Oracle Live SQL
create table t1_nocompress as select * from
(select rownum t1_id, object_id p1, object_name p2, owner p3 from all_objects),(select rownum from dual CONNECT BY LEVEL <=2);
select segment_name,blocks,bytes/1024 bytes_k from user_segments;
From that I got an 8192 Kb segment which may not be sufficiently big to see a real difference in size for different compression types, but I'll try anyway. Let's try to create an object with advanced compression and see if it saves us any space.
drop table t1_nocompress purge;
create table t1_advcompress row store compress advanced as select * from
(select rownum t1_id, object_id p1, object_name p2, owner p3 from all_objects),(select rownum from dual CONNECT BY LEVEL <=2);
So, instead of 8192 Kb, we have 7168 Kb. The savings of 1M of space is not very impressive. What if we tried Hybrid Columnar Compression (HCC)?
drop table t1_advcompress purge;
create table t1_hccquerylow column store compress for query low as select * from
(select rownum t1_id, object_id p1, object_name p2, owner p3 from all_objects),(select rownum from dual CONNECT BY LEVEL <=2);
The segment size decreased to 2048 Kb or 4 times. That looks way better. What if we try the HCC with query high compression level?
drop table t1_hccquerylow purge;
create table t1_hccqueryhigh column store compress for query high as select * from
(select rownum t1_id, object_id p1, object_name p2, owner p3 from all_objects),(select rownum from dual CONNECT BY LEVEL <=2);
The segment was only 832 Kb which is almost a 10 times space reduction. As the result, we could create a table with 10 times more rows. The original table was created with 109054 rows.
drop table t1_hccqueryhigh purge;
create table t1_hccqueryhigh column store compress for query high as select * from
(select rownum t1_id, object_id p1, object_name p2, owner p3 from all_objects),(select rownum from dual CONNECT BY LEVEL <=20);
select count(*) from t1_hccqueryhigh;
Now we have a table with 1090540 rows and the segment size is still 8192 Kb. Hence, if you need a 1 million row table for your Oracle Live SQL test, HCC compression could be your savior. It is pretty good to have HCC compression and database in memory features on a free service for developers. It may help you to understand how it works and maybe test some of your scenarios. Happy coding everyone.
On this page
Share this
Share this
More resources
Learn more about Pythian by reading the following blogs and articles.
Oracle autonomous transaction processing - a good start
Oracle autonomous transaction processing - a good start
Aug 30, 2018 12:00:00 AM
4
min read
Bushy join trees in Oracle 12.2
Bushy join trees in Oracle 12.2
Apr 4, 2017 12:00:00 AM
3
min read
How to Find Objects Creating nologging Changes
How to Find Objects Creating nologging Changes
Sep 4, 2008 12:00:00 AM
4
min read
Ready to unlock value from your data?
With Pythian, you can accomplish your data transformation goals and more.