19.06.2013 Views

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

SHOW MORE
SHOW LESS

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

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

5.4 Volatile table<br />

5.4.1 Conclusion<br />

<strong>DB2</strong> V6 introduced a new parameter, NPGTHRSH, which will cause the <strong>DB2</strong> Optimizer to<br />

favor index access <strong>for</strong> tables whose statistics indicate fewer than a given number of pages.<br />

For a given table, if NPAGES is fewer than the NPGTHRSH value, index access <strong>for</strong> the table<br />

will be preferred over a table space scan. After the initial install of ERP application packages,<br />

there are many empty or small tables which could grow rapidly in size. There are also a<br />

number of tables which are very volatile, meaning the number of rows can change very<br />

quickly and in large amounts. If a RUNSTATS is run on these tables when they are small, the<br />

<strong>DB2</strong> optimizer would favor a table space scan, which would be inappropriate when the table<br />

grows. Prior to this enhancement, the recommendation was to update the catalog statistics<br />

<strong>for</strong> volatile tables.<br />

<strong>DB2</strong> V8 introduces the VOLATILE keyword on the CREATE and ALTER statements. A volatile<br />

table is a table whose contents can vary from zero to very large at run time. <strong>DB2</strong> often does a<br />

table space scan or non-matching index scan when the data access statistics indicate that a<br />

table is small, even though matching index access is possible. This is a problem if the table is<br />

small or empty when statistics are collected, but the table is large when it is queried. In that<br />

case, the statistics are not accurate and can lead <strong>DB2</strong> to pick an inefficient access path.<br />

Forcing index access may be desired <strong>for</strong> tables whose size can vary greatly.<br />

In some applications, and often with SAP, a <strong>DB2</strong> table, called a cluster table, can be made up<br />

of logical rows, with each logical row consisting of multiple physical rows from that table. A<br />

logical row is identified by the primary key with a “sequence number” appended to provide the<br />

logical ordering of the physical rows. When accessing this type of table, the physical rows are<br />

intended to be accessed in this order (primary key + sequence number). This reduces the<br />

chance of deadlocks occurring when two applications attempt to lock the same logical row but<br />

touch the underlying physical rows in a different order. This means that certain types of<br />

access paths are disabled <strong>for</strong> these types of tables. They are: list prefetch hybrid join and<br />

multi-index access.<br />

Although volatile tables and the NPGTHRSH subsystem parameter both cause <strong>DB2</strong> to favor<br />

index access, they behave differently and have different granularities. NPGTHRSH favors<br />

index access on a subsystem level when the number of pages drops below the threshold. The<br />

NPGTHRSH subsystem parameter causes <strong>DB2</strong> to prefer index access in all of these cases,<br />

even when statistics are not accurate. Volatile tables are designated at the table level instead<br />

of the subsystem level, which allows you to favor index access <strong>for</strong> specific tables and specific<br />

queries because only those tables that are defined as volatile favor index access. Finally,<br />

volatile tables differ from the NPGTHRSH subsystem parameter by further restricting the<br />

types of access to preserve the access sequence that is provided by the primary key.<br />

5.4.2 Recommendations<br />

Use the VOLATILE keyword on the CREATE table statement instead of the NPGTHRSH<br />

DSNZPARM parameter in order to favor index access <strong>for</strong> volatile and cluster tables at the<br />

table level.<br />

5.5 Index enhancements<br />

With the table-controlled partitioning concept in <strong>DB2</strong> V8, clustering, being partitioned, and<br />

being the partitioning index are now separate concepts. When using table-controlled<br />

partitioning, a table does not require a partitioning index, since the partitioning is based on<br />

246 <strong>DB2</strong> <strong>UDB</strong> <strong>for</strong> z/<strong>OS</strong> <strong>Version</strong> 8 Per<strong>for</strong>mance <strong>Topics</strong>

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

Saved successfully!

Ooh no, something went wrong!