05.11.2015 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 11 ■ INDEXES 441<br />

select * from colocated where x between 20000 <strong>and</strong> 40000<br />

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

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

Parse 5 0.00 0.00 0 0 0 0<br />

Execute 5 0.00 0.00 0 0 0 0<br />

Fetch 6675 0.59 0.60 0 14495 0 100005<br />

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

total 6685 0.59 0.60 0 14495 0 100005<br />

Rows Row Source Operation<br />

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

20001 TABLE ACCESS BY INDEX ROWID COLOCATED (cr=2899 pr=0 pw=0 time=120134 us)<br />

20001 INDEX RANGE SCAN COLOCATED_PK (cr=1374 pr=0 pw=0 time=40081 us)(object id...<br />

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

select /*+ index( disorganized disorganized_pk ) */* from disorganized<br />

where x between 20000 <strong>and</strong> 40000<br />

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

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

Parse 5 0.00 0.00 0 0 0 0<br />

Execute 5 0.00 0.00 0 0 0 0<br />

Fetch 6675 0.85 0.87 0 106815 0 100005<br />

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

total 6685 0.85 0.87 0 106815 0 100005<br />

Rows Row Source Operation<br />

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

20001 TABLE ACCESS BY INDEX ROWID DISORGANIZED (cr=21363 pr=0 pw=0 time=220144 ...<br />

20001 INDEX RANGE SCAN DISORGANIZED_PK (cr=1374 pr=0 pw=0 time=40311 us)(...<br />

■Note I ran each query five times in order to get a good “average” runtime for each.<br />

I think this is pretty incredible. What a difference physical data layout can make! Table 11-5<br />

summarizes the results.<br />

Table 11-5. Investigating the Effect of Physical Data Layout on the Cost of Index Access<br />

Table CPU Time Logical I/O<br />

Co-located 0.59 seconds 14,495<br />

Disorganized 0.85 seconds 106,815<br />

Co-located % 70% 13%

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

Saved successfully!

Ooh no, something went wrong!