Named vs Anonymous Pl/sql Blocks testing

yxyup發表於2008-04-20
1
begin
for i in 1..1000000
loop
begin select object_id into :a from test1 where rownum<2; end;
end loop;
end;
call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1    145.03     157.67          0    4000238          0           1
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2    145.03     157.67          0    4000238          0           1
2
begin
for i in 1..1000000
loop
select object_id into :a from test1 where rownum<2;
end loop;
end;
call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1    144.89     159.03          0    4000238          0           1
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2    144.89     159.03          0    4000238          0           1

3
BEGIN a; END;

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.03          0         51          0           0
Execute      1     79.24      91.40          0          0          0           1
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     79.27      91.44          0         51          0           1
/*create procedure a */
create or replace procedure a
is
i number ;
a number ;
begin
for i in 1..1000000 loop
select object_id into a from test1 where rownum<2;
end loop;
end;
/
 
 
從中可以看出在完成同樣工作的情況下,Anonymous Pl/sql Blocks 效能和Named效能相差很多

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7364032/viewspace-245930/,如需轉載,請註明出處,否則將追究法律責任。