表中有100w条记录.
一次需要执行 2w条update语句.每条update 都是针对表中的一条记录来更新.
意思就是只影响表中的2w条数据.
 .net 下.
begin
update ...............;
......
2w条end;需要6分钟.
--------------------------------------------
begin
end;
每50条提交一次需要2分半中.--------------------
日志功能没有开启, 索引去掉了.(单主键留着)还有没有更快的方法啊???????????????????

解决方案 »

  1.   

    你看看v$session_wait中的等待主要在哪一部分有等待?
      

  2.   

    SID SEQ# EVENT P1TEXT P1 P1RAW P2TEXT P2 P2RAW P3TEXT P3 P3RAW WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS WAIT_TIME SECONDS_IN_WAIT STATE133 68 SQL*Net message from client driver id 1413697536 54435000 #bytes 1 00000001 0 00 2723168908 6 Idle -1 0 WAITED SHORT TIME
    134 1450 SQL*Net message from client driver id 1413697536 54435000 #bytes 1 00000001 0 00 2723168908 6 Idle 0 1356 WAITING
    138 14584 Streams AQ: waiting for messages in the queue queue id 8808 00002268 process# 879044492 3465278C wait time 5 00000005 2723168908 6 Idle 0 0 WAITING
    139 6400 SQL*Net message from client driver id 1413697536 54435000 #bytes 1 00000001 0 00 2723168908 6 Idle 0 18 WAITING
    140 1 jobq slave wait 0 00 0 00 0 00 2723168908 6 Idle 0 19 WAITING
    149 11877 SQL*Net message from client driver id 1413697536 54435000 #bytes 1 00000001 0 00 2723168908 6 Idle 0 938 WAITING
    150 663 Streams AQ: waiting for time management or cleanup tasks 0 00 0 00 0 00 2723168908 6 Idle 0 1875 WAITING
    151 1 Streams AQ: qmn slave idle wait 0 00 0 00 0 00 2723168908 6 Idle 0 1063670 WAITING
    154 12 Streams AQ: qmn coordinator idle wait 0 00 0 00 0 00 2723168908 6 Idle 0 21969 WAITING
    156 35166 SQL*Net message from client driver id 675562835 28444553 #bytes 1 00000001 0 00 2723168908 6 Idle 0 9 WAITING
    158 45663 wait for unread message on broadcast channel channel context 868968600 33CB6898 channel handle 868935372 33CAE6CC 0 00 2723168908 6 Idle 0 12 WAITING
    159 18581 SQL*Net message from client driver id 675562835 28444553 #bytes 1 00000001 0 00 2723168908 6 Idle 0 120 WAITING
    160 202 rdbms ipc message timeout 100 00000064 0 00 0 00 2723168908 6 Idle 0 1536 WAITING
    161 57189 rdbms ipc message timeout 300 0000012C 0 00 0 00 2723168908 6 Idle 0 890 WAITING
    162 45011 rdbms ipc message timeout 500 000001F4 0 00 0 00 2723168908 6 Idle 0 21 WAITING
    163 50 rdbms ipc message timeout 180000 0002BF20 0 00 0 00 2723168908 6 Idle 0 8855 WAITING
    164 17237 smon timer sleep time 300 0000012C failed 0 00 0 00 2723168908 6 Idle 0 1102 WAITING
    165 8302 rdbms ipc message timeout 300 0000012C 0 00 0 00 2723168908 6 Idle 0 3 WAITING
    166 26030 rdbms ipc message timeout 300 0000012C 0 00 0 00 2723168908 6 Idle 0 0 WAITING
    167 28238 rdbms ipc message timeout 300 0000012C 0 00 0 00 2723168908 6 Idle 0 3 WAITING
    168 1506 rdbms ipc message timeout 300 0000012C 0 00 0 00 2723168908 6 Idle 0 1978 WAITING
    169 30023 rdbms ipc message timeout 300 0000012C 0 00 0 00 2723168908 6 Idle 0 18 WAITING
    170 37 pmon timer duration 300 0000012C 0 00 0 00 2723168908 6 Idle 0 18598 WAITING
    ----------------------------
    看不懂.....
      

  3.   

    你要在你update过程开始,但还没结束时看v$session_wait.
    你上面贴的那个没用。
      

  4.   

    在100万记录的表中执行2万次update,不用索引那就肯定根据主键查询了,否则不可能只用6分钟甚至2分半钟。阶段性提交之所以能提高效率,根本原因是及时释放了回滚段。至于每隔多少个更新提交,和你的数据库参数有关。你只能测试来获得最佳结果。要继续提高效率
    *. 看你的update语句是怎么写的。是否用了绑定变量?如果不用绑定变量的话,oracle每次都要hard parse语句,那就是额外的开销。
    *. 表的存储参数是否合理。如果表空间采用uniform block size而表的存储参数不合理的话,update会造成大量的chained blocks,那是很耗时的。
    *. 用.net或者任何其它的外部程序来执行update是否必要?更新用到的参数时从哪里来的?如果不需要从.net程序中拿,是否能直接放到数据库中执行?请楼主提供更详细的信息,才能继续讨论下去。
      

  5.   

    update tablename set XXX=345.6  where A='a' and B='b' and C='c'表中 keyid为唯一组件
    A,B,C 为复合主键
      

  6.   


    数据库基本上是 next 下来安装出来的, 应没有配置这些东西
      

  7.   


     update C_APP_COST_data  set myValue ='123.5'  where  dateflag='20090200' and cost_subj_code='abcd1234' and dept_id='34'
    实际就是更新某个单位下某个code 的09年2月的值.
    dateflag  cost_subj_code dept_id 为复合主键.另外还有keyID做唯一组件.因为没有用到"绑定变量" 吧.
    PS 什么是绑定变量?
    我个人认为 每次update 不大会增加数据库文件的存储.因为myValue 原来就是有值的我只是改变了这个值.并没有增加多少bit. 我是设置的每次固定增加100M.我们是默认安装,应该是固定块大小每块是 8492.
    这个应该是必须由net来执行. 因为这个值就是在net中算出来的.
      

  8.   

    试试批量更新,用 update tb1 set c1 where ......
      

  9.   

    建议使用动态绑定方式批量更新
    调用存储过程,在存储过程中写以下代码
    execute immediate 'update tablename set XXX=:1  where A=:2 and B=:3 and C=:4' using  123.5  ,'A','B','C';