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.

350<br />

CHAPTER 10 ■ DATABASE TABLES<br />

time), your buffer cache efficiency goes down (you need to buffer two blocks instead of just<br />

the one you would if the rows were not migrated), <strong>and</strong> your table grows in size <strong>and</strong> complexity.<br />

For these reasons, you do not want migrated rows.<br />

It is interesting to note what <strong>Oracle</strong> will do if the row that was migrated from the block on<br />

the left to the block on the right, in Figure 10-5, has to migrate again at some future point in<br />

time. This would be due to other rows being added to the block it was migrated to <strong>and</strong> then<br />

updating this row to make it even larger. <strong>Oracle</strong> will actually migrate the row back to the original<br />

block <strong>and</strong>, if there is sufficient space, leave it there (the row might become “unmigrated”).<br />

If there isn’t sufficient space, <strong>Oracle</strong> will migrate the row to another block altogether <strong>and</strong><br />

change the forwarding address on the original block. As such, row migrations will always<br />

involve one level of indirection.<br />

So, now we are back to PCTFREE <strong>and</strong> what it is used for: it is the setting that will help you to<br />

minimize row chaining when set properly.<br />

Setting PCTFREE <strong>and</strong> PCTUSED Values<br />

Setting PCTFREE <strong>and</strong> PCTUSED is an important—<strong>and</strong> greatly overlooked—topic. In summary,<br />

PCTUSED <strong>and</strong> PCTFREE are both crucial when using MSSM; with ASSM, only PCTFREE is. On one<br />

h<strong>and</strong>, you need to use them to avoid too many rows from migrating. On the other h<strong>and</strong>, you<br />

use them to avoid wasting too much space. You need to look at your objects <strong>and</strong> describe how<br />

they will be used, <strong>and</strong> then you can come up with a logical plan for setting these values. Rules<br />

of thumb may very well fail you on these settings; they really need to be set based on usage.<br />

You might consider the following (keeping in mind that “high” <strong>and</strong> “low” are relative terms,<br />

<strong>and</strong> that when using ASSM only PCTFREE applies):<br />

• High PCTFREE,low PCTUSED: This setting is for when you insert lots of data that will be<br />

updated <strong>and</strong> the updates will increase the size of the rows frequently. This setting<br />

reserves a lot of space on the block after inserts (high PCTFREE) <strong>and</strong> makes it so that<br />

the block must almost be empty before getting back onto the freelist (low PCTUSED).<br />

• Low PCTFREE, high PCTUSED: This setting is for if you tend to only ever INSERT or DELETE<br />

from the table, or if you do UPDATE, the UPDATE tends to shrink the row in size.<br />

LOGGING <strong>and</strong> NOLOGGING<br />

Normally objects are created in a LOGGING fashion, meaning all operations performed against<br />

them that can generate redo will generate it. NOLOGGING allows certain operations to be performed<br />

against that object without the generation of redo; we covered this in the last chapter<br />

in some detail. NOLOGGING affects only a few specific operations, such as the initial creation of<br />

the object, or direct path loads using SQL*Loader, or rebuilds (see the <strong>Oracle</strong> SQL Reference<br />

manual for the database object you are working with to see which operations apply).<br />

This option does not disable redo log generation for the object in general—only for very<br />

specific operations. For example, if I create a table as SELECT NOLOGGING <strong>and</strong> then INSERT INTO ➥<br />

THAT_TABLE VALUES ( 1 ), the INSERT will be logged, but the table creation might not have been<br />

(the DBA can force logging at the database or tablespace level).

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

Saved successfully!

Ooh no, something went wrong!