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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Be<strong>for</strong>e ALTER INDEX add column, a table space scan was used to access the data. After<br />

ALTER INDEX ADD of an existing column of the table to an index, the index was placed in a<br />

RBDP state and needs to be rebuilt. After rebuild, the access path changed from table space<br />

scan to non-matching index scan showing a 10 times elapsed time improvement.<br />

Class 1 Time (seconds)<br />

120<br />

100<br />

Figure 5-10 SELECT elapsed and CPU time be<strong>for</strong>e and after ALTER INDEX add column<br />

Conclusion<br />

A change of the access path from table space scan to an access path using the index<br />

improves the elapsed time. This is well known. What is worth noting is the ease of<br />

implementing the change. Remember that an index in RBDP state does not block access to<br />

the data. For non-unique indexes, static plans and packages that do not use the index to<br />

retrieve data, they will continue to function as be<strong>for</strong>e. For unique indexes placed in RBDP,<br />

those plans and packages that are dependent on them will get a -904 (unavailable resource)<br />

on an update of an existing row or insert of a new row. Deletes are no problem. For the time<br />

until rebuild, the optimizer simply ignores the index <strong>for</strong> dynamic SQL; <strong>for</strong> static SQL a rebind is<br />

necessary.<br />

Recommendations<br />

Once the index is available again, revert to optimal access paths by:<br />

► Rebinding affected plans and packages <strong>for</strong> static SQL.<br />

► Automatic invalidation of related statements in the dynamic statement cache when RBDP<br />

is reset. At next execution, the statement is prepared again, and can go back to the<br />

original access path.<br />

Important: The enhancement is designed to allow maximum availability <strong>for</strong> the situations<br />

where a new column is added to a table, and this new column is also desired as part of an<br />

existing index. By making changes within the same unit of work there is no unavailability.<br />

236 <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><br />

80<br />

60<br />

40<br />

20<br />

0<br />

SELECT elapsed time and CPU time<br />

Elapsed Time CPU Time<br />

Be<strong>for</strong>e Alter After Rebuild<br />

Index<br />

Index<br />

(2) (5)<br />

1. DDL Create Index<br />

CREATE INDEX ix1 ON tab1(c1) ...<br />

2. SELECT c1, c2 … WHERE c2 = ‘xx‘<br />

Column not indexed, table space<br />

scan<br />

3. ALTER INDEX ix1 ADD COLUMN (c2)<br />

Index in RBDP<br />

4. Rebuild Index<br />

5. SELECT c1, c2 … WHERE c2 = ‘xx‘<br />

Non matching index only scan<br />

10+ times Elapsed time<br />

improvement

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

Saved successfully!

Ooh no, something went wrong!