我有一个Oracle SQL查询,在“GROUP BY”操作期间消耗了大量的临时空间。底层表有200亿条记录(18 GB)。我打算压缩该表,看看它是否有助于减少它占用的临时空间。我怀疑它可能没有,但有人经历过它吗?
提前致谢..
答案 0 :(得分:0)
基本表压缩不会减少临时表空间使用量。很难证明某些东西不存在,这是我的理由:
此示例显示正在分组的高度压缩的表。添加或删除compress
选项不会更改临时空间量。
--Create a table and add data.
drop table table1;
create table table1(
c1 char(100), c2 char(100), c3 char(100), c4 char(100), c5 char(100),
c6 char(100), c7 char(100), c8 char(100), c9 char(100), c10 char(100)
) compress; -- Remove "compress" and re-run to compare. Results will not change.
insert /*+ append */ into table1
select level,level,level,level,level,level,level,level,level,level
from dual connect by level <= 100000;
commit;
--There is about 95MB of data.
select 100000*100*10/1024/1024 mb from dual;
--Segment size is 13MB.
select bytes/1024/1024 from dba_segments where segment_name = 'TABLE1';
--Create a new table using a large GROUP BY.
drop table table2;
create table table2 as
select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10
from table1
group by c1,c2,c3,c4,c5,c6,c7,c8,c9,c10;
--In a separate session, measure the temporary tablespace usage.
--The value tops out at 89MB.
select bytes/1024/1024 mb from dba_segments where segment_name = 'TABLE1';