ahh, if you call dbms_lob.write* operations many times in succession -- yes. Here is my benchmark -- i use runstats (asktom.oracle.com/~tkyte) -- it measures more things. There is a definite and obvious difference on my test once you start doing THOUSANDS of write calls (abnormal, most people do a handful - usually one -- rarely thousands)
Here is my test case:
ops$tkyte@ORA920> create table t ( x clob );
Table created.
ops$tkyte@ORA920>
ops$tkyte@ORA920> create or replace procedure p( p_open_close in boolean default false,
2 p_iters in number default 100 )
3 as
4 l_clob clob;
5 begin
6 insert into t (x) values ( empty_clob() )
7 returning x into l_clob;
8
9 if ( p_open_close )
10 then
11 dbms_lob.open( l_clob, dbms_lob.lob_readwrite );
12 end if;
13
14 for i in 1 .. p_iters
15 loop
16 dbms_lob.WriteAppend( l_clob, 5, 'abcde' );
17 end loop;
18
19 if ( p_open_close )
20 then
21 dbms_lob.close( l_clob );
22 end if;
23 commit;
24 end;
25 /
Procedure created.
We can control whether the lob is opened/closed and how many writeAppends we do to it. The results for 100 writeAppends was marginal:
ops$tkyte@ORA920> exec runstats_pkg.rs_start;
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec p(FALSE,100);
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec runstats_pkg.rs_middle;
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec p(TRUE,100);
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec runstats_pkg.rs_stop(10000);
Run1 ran in 11 hsecs
Run2 ran in 9 hsecs
run 1 ran in 122.22% of the time
Name Run1 Run2 Diff
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
9,323 9,024 -299 103.31%
PL/SQL procedure successfully completed.
ops$tkyte@ORA920>
<b>
They more or less -- for all intents and purposes -- did the same amount of work in about the same amount of time.
Moving onto 1,000 iterations however</b>
ops$tkyte@ORA920> exec runstats_pkg.rs_start;
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec p(FALSE,1000);
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec runstats_pkg.rs_middle;
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec p(TRUE,1000);
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec runstats_pkg.rs_stop(10000);
Run1 ran in 111 hsecs
Run2 ran in 102 hsecs
run 1 ran in 108.82% of the time
Name Run1 Run2 Diff
STAT...session logical reads 38,219 12,897 -25,322
STAT...consistent changes 31,182 4,376 -26,806
STAT...data blocks consistent 30,673 3,859 -26,814
STAT...consistent gets - exami 32,022 5,206 -26,816
STAT...consistent gets 32,870 5,942 -26,928
LATCH.cache buffers chains 115,595 41,229 -74,366
STAT...session pga memory 107,996 7,812 -100,184
STAT...redo size 5,443,144 5,599,576 156,432
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
171,337 92,963 -78,374 184.31%
PL/SQL procedure successfully completed.
ops$tkyte@ORA920>
<b>we start to see something interesting -- first, the one without open/close is taking longer by the wall clock BUT more interesting is the latching that is going on. We almost doubled the latching by not opening/closing here. That inhibits scalability massively -- in a multi-user test, the one without open/close would not scale very well at all.
Moving upto 2,000 writeappends</b>
ops$tkyte@ORA920> exec runstats_pkg.rs_start;
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec p(FALSE,2000);
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec runstats_pkg.rs_middle;
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec p(TRUE,2000);
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec runstats_pkg.rs_stop(10000);
Run1 ran in 1258 hsecs
Run2 ran in 706 hsecs
run 1 ran in 178.19% of the time
Name Run1 Run2 Diff
STAT...db block gets 19,044 29,575 10,531
LATCH.undo global data 18,837 4,022 -14,815
LATCH.simulator hash latch 36,148 2,215 -33,933
STAT...redo size 15,471,664 15,910,000 438,336
STAT...consistent changes 1,741,844 11,075 -1,730,769
STAT...data blocks consistent 1,741,335 10,557 -1,730,778
STAT...session logical reads 1,783,277 46,937 -1,736,340
STAT...consistent gets - exami 1,753,600 13,920 -1,739,680
STAT...consistent gets 1,765,441 18,570 -1,746,871
LATCH.cache buffers chains 5,349,496 147,523 -5,201,973
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
5,541,018 277,802 -5,263,216 1,994.59%
PL/SQL procedure successfully completed.
ops$tkyte@ORA920>
<b>now the wall clock difference is very measurable -- but look at those latches! that is *huge*.
At 5,000</b>
ops$tkyte@ORA920> exec runstats_pkg.rs_start;
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec p(FALSE,5000);
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec runstats_pkg.rs_middle;
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec p(TRUE,5000);
PL/SQL procedure successfully completed.
ops$tkyte@ORA920> exec runstats_pkg.rs_stop(10000);
Run1 ran in 8925 hsecs
Run2 ran in 1956 hsecs
run 1 ran in 456.29% of the time
Name Run1 Run2 Diff
STAT...no work - consistent re 2,478 18,398 15,920
STAT...db block gets 64,682 96,602 31,920
STAT...db block changes 136,403 84,374 -52,029
STAT...redo entries 114,133 44,234 -69,899
LATCH.redo allocation 114,690 44,735 -69,955
LATCH.cache buffers lru chain 86,428 5,496 -80,932
STAT...free buffer requested 85,405 4,074 -81,331
STAT...calls to kcmgas 86,058 4,712 -81,346
STAT...cleanout - number of kt 84,750 378 -84,372
STAT...active txn count during 84,743 351 -84,392
STAT...immediate (CR) block cl 84,729 312 -84,417
STAT...cleanouts and rollbacks 84,722 288 -84,434
STAT...CR blocks created 84,750 288 -84,462
LATCH.undo global data 173,491 13,620 -159,871
LATCH.simulator hash latch 697,188 4,117 -693,071
STAT...redo size 48,304,392 46,655,964 -1,648,428
STAT...consistent changes 17,086,252 37,143 -17,049,109
STAT...data blocks consistent 17,085,741 36,626 -17,049,115
STAT...consistent gets - exami 17,179,776 46,216 -17,133,560
STAT...session logical reads 17,337,689 169,999 -17,167,690
STAT...consistent gets 17,277,215 77,605 -17,199,610
LATCH.cache buffers chains 52,010,113 508,652 -51,501,461
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
53,376,618 865,837 -52,510,781 6,164.74%
PL/SQL procedure successfully completed.
<b>now it is getting serious.
</b>