alter table nologging /*+APPEND PARALLEL(n)*/

                   最近系统中关键任务做了如下操作,
alter table table_name nologging;
alter session enable parallel dml;
insert into /*+append parallel(n)*/ table_name select xx left join xxx on xx.id = xxx.id;
commit;
alter table table_name logging;

注意:系统中允许table nologging,注意任务中表锁的情况,需要及时提交。

下面是测试结果:
--------------------------------------------------------------------------------
create table test1 as select * from test where 1=2;
[1]
insert into test1 
select a.* from (select * from test order by owner desc,object_id,status desc,sharing ,created ) 
a left join (select object_id ,count(owner) from test group by object_id ) b on a.object_id = 
b.object_id order by a.object_id desc;
Elapsed: 00:01:42.44
       3355  recursive calls
    2009619  db block gets
    1455125  consistent gets
     393476  physical reads
  2971133724  redo size
   18754752  rows processed

[2]
alter table test1 nologging;
insert into test1 
select a.* from (select * from test order by owner desc,object_id,status desc,sharing ,created ) 
a left join (select object_id ,count(owner) from test group by object_id ) b on a.object_id = 
b.object_id order by a.object_id desc;
Elapsed: 00:01:52.06
       3426  recursive calls
    2010276  db block gets
    1455523  consistent gets
     393476  physical reads
  2971157132  redo size
875  bytes sent via SQL*Net to client
       1167  bytes received via SQL*Net from client
  3  SQL*Net roundtrips to/from client
  4  sorts (memory)
  1  sorts (disk)
   18754752  rows processed
   
[3]
drop table test1 purge;
create table test1 as select * from test where 1=2;
alter table test1 nologging;
insert /*+append*/into test1 
select a.* from (select * from test order by owner desc,object_id,status desc,sharing ,created ) 
a left join (select object_id ,count(owner) from test group by object_id ) b on a.object_id = 
b.object_id order by a.object_id desc;
Elapsed: 00:00:53.17

       3588  recursive calls
     368898  db block gets
     727929  consistent gets
     393476  physical reads
      460940   redo size
    861  bytes sent via SQL*Net to client
       1186  bytes received via SQL*Net from client
      3  SQL*Net roundtrips to/from client
      3  sorts (memory)
      1  sorts (disk)
   18754752  rows processed
[4]
drop table test1 purge;
create table test1 as select * from test where 1=2;
alter table test1 nologging;
insert /*+append parallel(12)*/into test1 
select a.* from (select * from test order by owner desc,object_id,status desc,sharing ,created ) 
a left join (select object_id ,count(owner) from test group by object_id ) b on a.object_id = 
b.object_id order by a.object_id desc;
Elapsed: 00:00:23.98
       3476  recursive calls
     368906  db block gets
     728849  consistent gets
    1101962  physical reads
      460896   redo size
      3  SQL*Net roundtrips to/from client
      6  sorts (memory)
      4  sorts (disk)
   18754752  rows processed
[5]
drop table test1 purge;
create table test1 as select * from test where 1=2;
insert /*+ parallel(12)*/into test1 
select a.* from (select * from test order by owner desc,object_id,status desc,sharing ,created ) 
a left join (select object_id ,count(owner) from test group by object_id ) b on a.object_id = 
b.object_id order by a.object_id desc;
   
【结论】并行开的多避免磁盘排序,加相同的并行不加append时间是1分08秒,都加了是23秒,只加append时间介于两者之间。
所以先设置alter table test nologging; 然后sql写hint /*+append parallel(n)*/



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29990276/viewspace-2155434/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29990276/viewspace-2155434/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值