对于全局临时表,有一个非常闪耀的亮点就是可以避免大量的redo产生,这是我们都知道的。文档68098.1中也有说明。
其实在对全局临时表做DML操作时,还是会产生一些redo的,这部分主要来自于undo,文档848852.1中也有说明。
那么,写这篇文章的目的就是想通过一个测试提醒大家,使用全局临时表,有时也会产生大量的redo。特别是在delete操作的时候,所以,如果使用全局临时表的出发点在于减少redo,那么要引起注意,请参照如下的测试:
———————————————————————–
1,create global temporary table temp
SQL>create global temporary table temp as select * from dba_objects;
2,check there is no record
SQL> select count(*) from temp;
COUNT(*)
———-
0
3,enable autotrace
SQL>set autotrace on
4,insert into data
SQL> insert into temp select * from dba_objects;
18181 rows created.
Statistics
———————————————————-
733 recursive calls
1359 db block gets
1149 consistent gets
129 physical reads
99056 redo size <<<<<<<<<99K redo
843 bytes sent via SQL*Net to client
799 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
91 sorts (memory)
0 sorts (disk)
18181 rows processed
5,delete data
SQL> delete from temp;
Statistics
———————————————————-
53 recursive calls
19629 db block gets
348 consistent gets
0 physical reads
5499048 redo size <<<<<<<<<<5M redo size
844 bytes sent via SQL*Net to client
773 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
18181 rows processed