create or replace procedure kq_num2 is
begin
declare
v_insert_num number(18,0);
begin
update plugs_mat t set t.sex = null,num2=null where sex = 400 ;
v_insert_num := 600;
for i in 1 .. v_insert_num loop
update plugs_mat set num2= trunc(dbms_random.value(1,101))
where status = 400 ;
end loop;
update plugs_mat t set t.sex = 400 where status=400 and num2<60 ;
end;end kq_num2;上面的过程,执行起来要2分钟左右,数据表的数据并不多,总共有22659但符合条件才不到1000条,为什么会这么慢,哪还可以优化,或者怎么样判断耗时耗在哪了
相关上的谓词索引已经建立了
begin
declare
v_insert_num number(18,0);
begin
update plugs_mat t set t.sex = null,num2=null where sex = 400 ;
v_insert_num := 600;
for i in 1 .. v_insert_num loop
update plugs_mat set num2= trunc(dbms_random.value(1,101))
where status = 400 ;
end loop;
update plugs_mat t set t.sex = 400 where status=400 and num2<60 ;
end;end kq_num2;上面的过程,执行起来要2分钟左右,数据表的数据并不多,总共有22659但符合条件才不到1000条,为什么会这么慢,哪还可以优化,或者怎么样判断耗时耗在哪了
相关上的谓词索引已经建立了
for i in 1 .. v_insert_num loop
update plugs_mat set num2= trunc(dbms_random.value(1,101))
where status = 400 ;
end loop;你这句是什么意思,吧STATUS=400的所有记录更新600遍。
如果num2上加了索引,那更新索引的时间也不短。
update plugs_mat set num2= trunc(dbms_random.value(1,101))
where status = 400 ;
v_insert_num number(18,0);
begin
update plugs_mat t set t.sex = null,num2=null where sex = 400 ;
v_insert_num := 600;
update plugs_mat set num2= trunc(dbms_random.value(1,101))
where status = 400 ;
update plugs_mat t set t.sex = 400 where status=400 and num2<60 ;
end;