与hard parse对比测试;
scott@MWDB> create table t ( x int );
表已创建。
scott@MWDB> create or replace PRocedure proc12 as3 begin4 for i in 1 .. 100005 loop6 execute immediate7 'insert into t values ( :x )' using i;8 end loop;9 end;10 /过程已创建。
scott@MWDB> create or replace procedure proc22 as3 begin4 for i in 1 .. 100005 loop6 execute immediate7 'insert into t values ( 'i')';8 end loop;9 end;10 /
过程已创建。
运行对比测试的小程序:
exec runstats_pkg.rs_startexec proc1exec runstats_pkg.rs_middleexec proc2exec runstats_pkg.rs_stop(1000)测试结果:
Run1 ran in 180 hsecsRun2 ran in 764 hsecsrun 1 ran in 23.56% of the timeName Run1 Run2 DiffSTAT...recursive calls 10,124 12,243 2,119STAT...redo size 2,316,668 2,310,452 -6,216LATCH.cache buffers chains 73,789 81,264 7,475STAT...parse count (hard) 2 10,014 10,012LATCH.library cache pin 80,200 95,846 15,646LATCH.library cache pin alloca 40,113 62,894 22,781LATCH.session allocation 24 31,209 31,185LATCH.row cache enqueue latch 112 41,612 41,500LATCH.row cache objects 128 41,774 41,646LATCH.child cursor hash table 18 70,980 70,962LATCH.library cache 110,365 239,250 128,885STAT...session pga memory 0 131,072 131,072LATCH.shared pool 50,234 259,418 209,184Run1 latches total versus runs -- difference and pctRun1 Run2 Diff Pct366,906 938,493 571,587 39.10%
PL/SQL 过程已成功完成。