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 10 ■ DATABASE TABLES 365<br />

To test that theory, we’ll rebuild the IOT with COMPRESS 1 first:<br />

ops$tkyte@ORA10GR1> alter table iot move compress 1;<br />

Table altered.<br />

ops$tkyte@ORA10GR1> analyze index iot_pk validate structure;<br />

Index analyzed.<br />

ops$tkyte@ORA10GR1> select lf_blks, br_blks, used_space,<br />

2 opt_cmpr_count, opt_cmpr_pctsave<br />

3 from index_stats;<br />

LF_BLKS BR_BLKS USED_SPACE OPT_CMPR_COUNT OPT_CMPR_PCTSAVE<br />

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

247 1 1772767 2 23<br />

As you can see, the index is in fact smaller: about 1.7MB, with fewer leaf blocks <strong>and</strong> many<br />

fewer branch blocks. But now it is saying, “You still can get another 23 percent off,” as we didn’t<br />

chop off that much yet. Let’s rebuild with COMPRESS 2:<br />

ops$tkyte@ORA10GR1> alter table iot move compress 2;<br />

Table altered.<br />

ops$tkyte@ORA10GR1> analyze index iot_pk validate structure;<br />

Index analyzed.<br />

ops$tkyte@ORA10GR1> select lf_blks, br_blks, used_space,<br />

2 opt_cmpr_count, opt_cmpr_pctsave<br />

3 from index_stats;<br />

LF_BLKS BR_BLKS USED_SPACE OPT_CMPR_COUNT OPT_CMPR_PCTSAVE<br />

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

190 1 1359357 2 0<br />

Now we are significantly reduced in size, both by the number of leaf blocks as well as<br />

overall used space, about 1.3MB. If we go back to the original numbers,<br />

ops$tkyte@ORA10GR1> select (2/3) * 2037497 from dual;<br />

(2/3)*2037497<br />

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

1358331.33<br />

then we can see the OPT_CMPR_PCTSAVE was dead-on accurate. The preceding example points<br />

out an interesting fact with IOTs. They are tables, but only in name. Their segment is truly an<br />

index segment.

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

Saved successfully!

Ooh no, something went wrong!