自己可以试一下insert的速度,是不是比较慢?

解决方案 »

  1.   

    如果有索引的话,也会影响insert的速度。
      

  2.   

    首先先把程序优化一下啊,第一个 if sf_isexist_ticket(sf_switch_ticketid(v_ticket_id))=0 then 既然这里判断了后面在insert的时候还要判断,会影响速度,第二,为什么还要定义那么多的变量,直接将游标的值赋进去就是了,还要赋来赋去吗?会影响速度.还有下面的语句是什么意思啊.假如是关闭游标的话,直接在insert后直接close cursor_name 就可以了.
                  fetch c_source_new into vv_rowvalue;
                  end loop;
                  close c_source_new;
             else
             dbms_output.put_line(v_old_customer_id||';'||v_new_customer_id);
             --null;
             end if;
             
             fetch c_source into v_rowvalue;
             end loop;
             close c_source;
    我想最能影响速度的应该是你insert时候的写的函数了.把它贴出来看看.相信几万条数据只要几分钟,那要半个小时.太夸张了.
      

  3.   

    第一个 if sf_isexist_ticket(sf_switch_ticketid(v_ticket_id))=0 then 是用来判断是否在表中已经存在这条记录,如果=0也就不存在才进行下面的insert操作,里面用了很多涵数是我对数据格式进行转换的如ID=123我要把他转成00123,我改成不用变量再看看先
      

  4.   

    select * from tbl_ticket030722 where customer_id=p_old_customer_id;--此句有了索引吗?
    绝非不用游标好
      

  5.   

    你的INSERT中VALUES值是由函数得到的。
    可能是瓶颈。
    把调用的函数中的SQL语句贴出来看看分析一下。
      

  6.   

    我的select 没有索引,但insert 的表有索引,我的涵数只是把数据进行了简单的转换,如
    function sf_switch_status(p_hidden in number) 
        return number
        is
          v_status   number(1);
          begin
          if p_hidden=1 then
             v_status:=0;
          elsif p_hidden=0 then
             v_status:=1;
          else
             v_status:=0;
          end if;
          return v_status;
           
        end sf_switch_status;
      

  7.   

    直接update语句啊,不要写函数了.把过程写在后台
      

  8.   

    哈哈,知道为什么这么慢吗..发现一个关键的问题,你的游标打开方式有问题,
             open c_source;
             fetch c_source into v_rowvalue;
             while c_source%found loop
    这中方式打开我真的没有见过,要不用下面两种方式打开,都可以啊.
    for v_rowvalue in c_source loop
      . ...
    end loopopen c_source;
    loop
      fetch c_source into v_rowvalue;
      exit when c_source%notfound;  .....
    end loop;
    close c_source;速度可以提高90%喔,先看看速度,有问题再说.
      

  9.   

    to 楼上的
    open c_source;
             fetch c_source into v_rowvalue;
             while c_source%found loop
    我是用while循环来提取游标,没什么错语呀,你怎么会没见过呢!!
    致于是不是while循环的效率比for和和loop... end loop底,书上我倒没见到过,不过我还是试试看先!!