05.11.2015 Views

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 10 ■ DATABASE TABLES 383<br />

ops$tkyte@ORA10GR1> exec runstats_pkg.rs_stop(10000);<br />

Run1 ran in 263 hsecs<br />

Run2 ran in 268 hsecs<br />

run 1 ran in 98.13% of the time<br />

Name Run1 Run2 Diff<br />

LATCH.cache buffers chains 99,891 148,031 48,140<br />

STAT...Cached Commit SCN refer 48,144 0 -48,144<br />

STAT...no work - consistent re 48,176 0 -48,176<br />

STAT...cluster key scans 48,176 0 -48,176<br />

STAT...cluster key scan block 48,176 0 -48,176<br />

STAT...table fetch by rowid 0 48,176 48,176<br />

STAT...rows fetched via callba 0 48,176 48,176<br />

STAT...buffer is not pinned co 48,176 96,352 48,176<br />

STAT...index fetch by key 0 48,176 48,176<br />

STAT...session logical reads 48,901 145,239 96,338<br />

STAT...consistent gets 48,178 144,530 96,352<br />

STAT...consistent gets from ca 48,178 144,530 96,352<br />

STAT...consistent gets - exami 1 144,529 144,528<br />

Run1 latches total versus runs -- difference <strong>and</strong> pct<br />

Run1 Run2 Diff Pct<br />

347,515 401,961 54,446 86.45%<br />

Now, these two simulations ran in about the same amount of time by the wall clock. As I<br />

had a buffer cache larger than large enough to cache these results, I was expecting that. The<br />

material difference to note, however, is the large reduction in cache buffers chains latches.<br />

The first implementation (hashed) used significantly fewer, meaning the hashed implementation<br />

should scale better in a read-intensive environment, since it needs fewer resources that<br />

require some level of serialization. This was due entirely to the fact that the I/O needed by the<br />

hashed implementation was significantly reduced over the HEAP table—you can see the statistic<br />

consistent gets in that report bears this out. The TKPROF shows it even more clearly:<br />

SELECT * FROM T_HASHED WHERE OBJECT_ID = :B1<br />

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

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

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

Execute 48174 4.77 4.83 0 2 0 0<br />

Fetch 48174 1.50 1.46 0 48174 0 48174<br />

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

total 96349 6.27 6.30 0 48176 0 48174<br />

Rows Row Source Operation<br />

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

48174 TABLE ACCESS HASH T_HASHED (cr=48174 pr=0 pw=0 time=899962 us)<br />

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

SELECT * FROM T_HEAP WHERE OBJECT_ID = :B1

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

Saved successfully!

Ooh no, something went wrong!