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.

342<br />

CHAPTER 10 ■ DATABASE TABLES<br />

of 1, you might find that your insert/update-intensive segments may be suffering from contention<br />

on free space allocation. When <strong>Oracle</strong> goes to insert a row into a table, or update an<br />

index key entry, or update a row causing the row to migrate (more on that in a moment as<br />

well), it may need to get a block from the list of free blocks associated with the segment. If<br />

there is only one list, only one transaction at a time may review <strong>and</strong> modify this list—they<br />

would have to wait for each other. Multiple FREELISTS <strong>and</strong> FREELIST GROUPS serve the purpose<br />

of increasing concurrency in such a case, as the transactions may each be looking at different<br />

lists <strong>and</strong> not contending with each other.<br />

When I discuss the storage settings shortly, I will mention which are for manual <strong>and</strong><br />

which are for automatic segment space management, but in the area of storage/segment<br />

characteristics, the only storage settings that apply to ASSM segments are as follows:<br />

• BUFFER_POOL<br />

• PCTFREE<br />

• INITRANS<br />

• MAXTRANS (only in 9i; in 10g this is ignored for all segments)<br />

The remaining storage <strong>and</strong> physical attribute parameters do not apply to ASSM segments.<br />

Segment space management is an attribute inherited from the tablespace in which a<br />

segment is contained (<strong>and</strong> segments never span tablespaces). For a segment to use ASSM,<br />

it would have to reside in a tablespace that supported that method of space management.<br />

High-Water Mark<br />

This is a term used with table segments stored in the database. If you envision a table, for<br />

example, as a “flat” structure or as a series of blocks laid one after the other in a line from left<br />

to right, the high-water mark (HWM) would be the rightmost block that ever contained data,<br />

as illustrated in Figure 10-1.<br />

Figure 10-1 shows that the HWM starts at the first block of a newly created table. As data<br />

is placed into the table over time <strong>and</strong> more blocks get used, the HWM rises. If we delete some<br />

(or even all) of the rows in the table, we might have many blocks that no longer contain data,<br />

but they are still under the HWM, <strong>and</strong> they will remain under the HWM until the object is<br />

rebuilt, truncated, or shrunk (shrinking of a segment is a new <strong>Oracle</strong> 10g feature that is supported<br />

only if the segment is in an ASSM tablespace).<br />

The HWM is relevant since <strong>Oracle</strong> will scan all blocks under the HWM, even when they<br />

contain no data, during a full scan. This will impact the performance of a full scan—especially<br />

if most of the blocks under the HWM are empty. To see this, just create a table with 1,000,000<br />

rows (or create any table with a large number of rows), <strong>and</strong> then execute a SELECT COUNT(*)<br />

from this table. Now, DELETE every row in it <strong>and</strong> you will find that the SELECT COUNT(*) takes<br />

just as long (or longer, if you need to clean out the block; refer to the “Block Cleanout” section<br />

of Chapter 9) to count 0 rows as it did to count 1,000,000. This is because <strong>Oracle</strong> is busy reading<br />

all of the blocks below the HWM to see if they contain data. You should compare this to<br />

what happens if you used TRUNCATE on the table instead of deleting each individual row.<br />

TRUNCATE will reset the HWM of a table back to “zero” <strong>and</strong> will truncate the associated indexes<br />

on the table as well. If you plan on deleting every row in a table, TRUNCATE—if it can be used—<br />

would be the method of choice for this reason.

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

Saved successfully!

Ooh no, something went wrong!