Oracle High Performance Tuning for 9i and 10g

 < Day Day Up > 


I like to make a distinction between physical block attributes and extent attributes. A block is a subset of an extent. Blocks contain data values. Extents are added to datafiles when a database object such as a table requires more physical datafile space and none can be allocated from existing unused extents. Extents can be sized and blocks can have specific allocation behaviors.

In this section we will discuss what is known as either the segments clause or the physical attributes clause. We will cover the storage clause later in this chapter. Physical attributes affect the physical structure of blocks and apply to objects such as tables, indexes, or clusters. Some factors apply to all object types and some apply to specific object types

14.7.1 What is in a Block?

A data block is the smallest unit of storage in a database. The block format is the same regardless of the type of object the data block contains. In general, an Oracle database block is divided into specific parts. These parts could be described vaguely as follows:

14.7.2 Block Space Management

Two parameters or settings are used to control how physical space is used in a block. PCTUSED determines how much space is required before rows can be inserted into a block. PCTFREE determines how much space is left free in a block when that block is first added to.

Tip 

Setting values for PCTUSED, FREELIST, and FREELIST_ GROUPS in database objects such as tables will be ignored if the containing tablespace is set to automatic segment space management.

Default values for PCTUSED and PCTFREE are 40% and 10%, respectively.

By no means do the Oracle Database default values have to be used. In fact it is advisable to change these values for certain types of combinations of DML activities on table and indexes.

Let's go through the process of tuning the block structure in the Accounts schema. My Accounts schema is a heavily concurrent DML intensive database. I will also adjust the approach assuming that an application would be running against this schema, including some reporting based on content in tables. First of all take a look at Figure 14.6. Figure 14.6 shows all tables with rows and blocks occupied after statistics generation.

Figure 14.6: Accounts Schema Current Row and Block Numbers

The number of rows in a table and the number of blocks occupied are important with respect to both DML and SELECT activity. Searching fewer rows is faster. Searching less physical space is also better. On the contrary, a few rows being accessed by many sessions using DML statements, all at once, can cause performance problems. Accessing a lot of rows in a single block is good for data retrieval but not for concurrent changes.

Possible changes for PCTUSED and PCTFREE parameters are shown in Figure 14.7. Index block structures must be changed in the same way that their respective tables are changed. This is because indexes undergo the same DML and SELECT activity as their respective tables.

Figure 14.7: Changes to Block Structure Space Usage

What exactly have I done in Figure 14.7? That is the question that should be asked. I have done various things for various reasons. Let's work through a list to break it up into easily understandable pieces.

What are influential factors for altering PCTUSED and PCTFREE?

Now I will group the tables and examine why I changed values for each table grouping.

Assessing PCTFREE Settings

A vague attempt can be made at assessing PCTFREE settings using a query such as this.

COL Table FORMAT a16; COL Rows FORMAT 9999999; COL Blocks FORMAT 9999999; COL RPB FORMAT 9999999 HEADING "Rows/Block"; COL SU FORMAT 9999999 HEADING "Space Free %"; SELECT table_name "Table", num_rows "Rows", blocks "Blocks" ,num_rows/blocks AS RPB, ROUND(avg_space/8192*100) AS SU ,chain_cnt "Chaining" FROM user_tables ORDER BY table_name;

Here are the results. Note that no changes have been made to PCTUSED and PCTFREE values in the Accounts schema at the time of execution of this query. All tables over 1,000 rows have over 10% of free space. This is a particularly obvious problem for the GeneralLedger and StockMovement tables because they never have any update activity.

Table Rows Blocks Rows/Block Space Free % Chaining -------------- ------- ------ ---------- ------------ -------- CASHBOOK 450957 4067 111 13 0 CASHBOOKLINE 2529733 6557 386 11 0 CATEGORY 13 1 13 96 0 COA 55 1 55 77 0 CUSTOMER 2694 60 45 17 0 GENERALLEDGER 2158809 9654 224 10 0 ORDERS 435076 1924 226 13 0 ORDERSLINE 2866927 9757 294 12 0 PERIOD 72 1 72 68 0 PERIODSUM 221 1 221 35 0 POSTING 8 1 8 94 0 STOCK 118 4 30 27 0 STOCK- 3032315 12937 234 10 0    MOVEMENT STOCKSOURCE 12083 30 403 15 0 SUBTYPE 4 1 4 98 0 SUPPLIER 3874 85 46 16 0 TRANSACTIONS 450957 3091 146 13 0 TRANSACTIONS- 2896275 9847 294 12 0 LINE TYPE 6 1 6 98 0

14.7.3 Block Concurrency

Block-level concurrency determines the number of locks which can be placed on a block. Concurrency capacity is the ability for rows in the same block to be accessed by multiple sessions at the same time, for both DML and SELECT activity. At the block level the parameters INITRANS and MAXTRANS help to control block concurrency. The INITRANS parameter can be increased for higher levels of concurrency.

Let's look once again at the Accounts schema to determine appropriate changes to INITRANS parameters. I will not alter MAXTRANS parameter values. Possible changes to INITRANS are shown in Figure 14.8.

Figure 14.8: Changes to Block Structure Concurrency

In Figure 14.8 INITRANS values have been adjusted to account for potential DML activity concurrency; multiple transactions are changing rows in the same block at once.

Most drastically changed are the COA and PeriodSum tables based on their high amount of DML activity. The Stock table INITRANS value is lower since it occupies more physical blocks than the other two tables (see Figure 14.6). The large static tables have INITRANS set to 2 because they are subject to concurrent UPDATE command activity. Setting INITRANS to 2 for the GeneralLedger and StockMovement tables is probably an unwise choice. These tables are subject to intense INSERT command activity. A reduction in concurrency problems could probably be resolved by changing their sequence number generated primary keys into reverse key indexes. Reverse key indexes would prevent concurrent sequential insertions of similar key values into the same block for the primary key index.

Tip 

Blocks already created cannot have their PCTUSED, PCTFREE, INITRANS, and MAXTRANS parameters changed. Changes only apply to new blocks.


 < Day Day Up > 

Категории