Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

rekharaghuram
from rekharaghuram More from this publisher
05.11.2015 Views

CHAPTER 12 ■ DATATYPES 547 buffer cache to be used for this. Also, if there were some really large LOBs in there, we might not really want this data to be cached. This in-row/out-of-row storage will affect modifications as well as reads. If we were to update the first 100 rows with short strings and insert 100 new rows with short strings, and use the same techniques to monitor performance, we would observe the following: ops$tkyte@ORA10G> create sequence s start with 100000; Sequence created. ops$tkyte@ORA10G> declare 2 l_cnt number; 3 l_data varchar2(32765); 4 begin 5 dbms_monitor.session_trace_enable; 6 for i in 1 .. 100 7 loop 8 update t set in_row = to_char(sysdate,'dd-mon-yyyy hh24:mi:ss') where id = i; 9 update t set out_row = to_char(sysdate,'dd-mon-yyyy hh24:mi:ss') where id = i; 10 insert into t (id, in_row) values ( s.nextval, 'Hello World' ); 11 insert into t (id,out_row) values ( s.nextval, 'Hello World' ); 12 end loop; 13 end; 14 / PL/SQL procedure successfully completed. We would discover findings similar to this in the resulting TKPROF report: UPDATE T SET IN_ROW = TO_CHAR(SYSDATE,'dd-mon-yyyy hh24:mi:ss') WHERE ID = :B1 call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 100 0.05 0.02 0 200 202 100 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 101 0.05 0.02 0 200 202 100 Rows Row Source Operation ------- --------------------------------------------------- 100 UPDATE (cr=200 pr=0 pw=0 time=15338 us) 100 INDEX UNIQUE SCAN SYS_C0011949 (cr=200 pr=0 pw=0 time=2437 us) ******************************************************************************** UPDATE T SET OUT_ROW = TO_CHAR(SYSDATE,'dd-mon-yyyy hh24:mi:ss') WHERE ID = :B1

548 CHAPTER 12 ■ DATATYPES call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 100 0.07 0.14 0 1100 2421 100 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 101 0.07 0.14 0 1100 2421 100 Rows Row Source Operation ------- --------------------------------------------------- 100 UPDATE (cr=1100 pr=0 pw=100 time=134959 us) 100 INDEX UNIQUE SCAN SYS_C0011949 (cr=200 pr=0 pw=0 time=2180 us) Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ direct path write 200 0.00 0.00 As you can see, the update of the out-of-line LOB consumed measurably more resources. It spent some amount of time doing direct path writes (physical I/O) and performed many more current mode gets as well as query mode gets. These were in response to the fact that the lobindex and lobsegment had to be maintained in addition to the table itself. The INSERT activity shows the same disparity: INSERT INTO T (ID, IN_ROW) VALUES ( S.NEXTVAL, 'Hello World' ) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 100 0.03 0.02 0 2 316 100 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 101 0.03 0.02 0 2 316 100 ******************************************************************************** INSERT INTO T (ID,OUT_ROW) VALUES ( S.NEXTVAL, 'Hello World' ) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 100 0.08 0.13 0 605 1839 100 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 101 0.08 0.13 0 605 1839 100 Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ direct path write 200 0.00 0.00

548<br />

CHAPTER 12 ■ DATATYPES<br />

call count cpu elapsed disk query current rows<br />

------- ------ -------- ---------- ---------- ---------- ---------- ----------<br />

Parse 1 0.00 0.00 0 0 0 0<br />

Execute 100 0.07 0.14 0 1100 2421 100<br />

Fetch 0 0.00 0.00 0 0 0 0<br />

------- ------ -------- ---------- ---------- ---------- ---------- ----------<br />

total 101 0.07 0.14 0 1100 2421 100<br />

Rows Row Source Operation<br />

------- ---------------------------------------------------<br />

100 UPDATE (cr=1100 pr=0 pw=100 time=134959 us)<br />

100 INDEX UNIQUE SCAN SYS_C0011949 (cr=200 pr=0 pw=0 time=2180 us)<br />

Elapsed times include waiting on following events:<br />

Event waited on Times Max. Wait Total Waited<br />

---------------------------------------- Waited ---------- ------------<br />

direct path write 200 0.00 0.00<br />

As you can see, the update of the out-of-line LOB consumed measurably more resources.<br />

It spent some amount of time doing direct path writes (physical I/O) <strong>and</strong> performed many<br />

more current mode gets as well as query mode gets. These were in response to the fact that<br />

the lobindex <strong>and</strong> lobsegment had to be maintained in addition to the table itself. The INSERT<br />

activity shows the same disparity:<br />

INSERT INTO T (ID, IN_ROW) VALUES ( S.NEXTVAL, 'Hello World' )<br />

call count cpu elapsed disk query current rows<br />

------- ------ -------- ---------- ---------- ---------- ---------- ----------<br />

Parse 1 0.00 0.00 0 0 0 0<br />

Execute 100 0.03 0.02 0 2 316 100<br />

Fetch 0 0.00 0.00 0 0 0 0<br />

------- ------ -------- ---------- ---------- ---------- ---------- ----------<br />

total 101 0.03 0.02 0 2 316 100<br />

********************************************************************************<br />

INSERT INTO T (ID,OUT_ROW) VALUES ( S.NEXTVAL, 'Hello World' )<br />

call count cpu elapsed disk query current rows<br />

------- ------ -------- ---------- ---------- ---------- ---------- ----------<br />

Parse 1 0.00 0.00 0 0 0 0<br />

Execute 100 0.08 0.13 0 605 1839 100<br />

Fetch 0 0.00 0.00 0 0 0 0<br />

------- ------ -------- ---------- ---------- ---------- ---------- ----------<br />

total 101 0.08 0.13 0 605 1839 100<br />

Elapsed times include waiting on following events:<br />

Event waited on Times Max. Wait Total Waited<br />

---------------------------------------- Waited ---------- ------------<br />

direct path write 200 0.00 0.00

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!