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.

EVE.EXT = 'ADD BILL' AND EVE.TXC = 'IBIA0102'<br />

In the query match with the predicates<br />

EVE.EXT = 'ADD BILL' AND EVE.TXC = 'IBIA0102'<br />

In the MQT due to join predicates.<br />

The predicate<br />

COV.CVT = 'P'<br />

3.2.5 Conclusions<br />

filters to one aggregation in the MQT because of GROUP BY COV.CVT.<br />

The measurements show a per<strong>for</strong>mance improvement in elapsed time from 10.5 sec. to 0.91<br />

sec. (about 91%) when using the MQT.<br />

Note that an expression like (A+B)*C cannot be derived from A*C+B*C.<br />

MQT considerations<br />

► All MQTs and their indexes are dropped if their associated base tables are dropped.<br />

► No primary keys, unique indexes or triggers are allowed on MQTs.<br />

► Design issues between a few generic MQTs and many more specialized MQTs:<br />

– Trade off between query per<strong>for</strong>mance and MQT maintenance.<br />

– Identify a set of queries which consume a lot of resource. Design MQTs <strong>for</strong> the set of<br />

queries as a starting point. Example: Top queries that consume a large amount of<br />

resources.<br />

► Automatic query rewrite is done at query block level by the <strong>DB2</strong> optimizer.<br />

► MQTs are not used <strong>for</strong> short running queries.<br />

► Query rewrite works <strong>for</strong> both star join and non-star join queries.<br />

► Code the predicates in the query in exactly the same way as they are in the MQT<br />

fullselect.<br />

Exception: The order of the items in the IN list predicate does not need to be in exactly the<br />

same order.<br />

MQTs can be created as a precomputed join, sort or aggregation, and reused by <strong>DB2</strong> query<br />

rewrite in dynamic SQL to improve the execution of long running queries in the Data<br />

Warehouse environment, providing largely reduced elapsed time and CPU time.<br />

► Query rewrite time seems reasonable <strong>for</strong> simple queries.<br />

► Query rewrite time grows reasonably when the number of eligible MQTs increases.<br />

► Query rewrite works. The query result can be obtained directly from the MQT or derived<br />

from the MQT.<br />

► Query rewrite can select the best MQT from a set of qualified MQTs.<br />

► Up to 100 times query per<strong>for</strong>mance improvement is observed; simple examples with<br />

tables that are not so large, show improvement of 22x, 31x, and 47x in elapsed time and<br />

70x, 236x and 117x in CPU time.<br />

52 <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!