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.

The most important factor in the return on investment on MQTs remains the frequency of<br />

utilization, and, there<strong>for</strong>e, a balance of how specialized the MQT is and how well it per<strong>for</strong>ms<br />

versus the range of applicability.<br />

3.2.6 Recommendations<br />

MQTs allow more flexibility <strong>for</strong> the physical data base design of tables at the detailed level<br />

(sometimes known as atomic level) in a corporate data warehouse. The base tables can be<br />

more normalized, closer to the conceptual model, and the per<strong>for</strong>mance issues of long running<br />

queries involving joins, summarizations, and subqueries can be resolved when materialized<br />

as MQTs.<br />

Plan MQTs <strong>for</strong> the top consuming queries, not <strong>for</strong> all queries. Use MQTs to aggregate results<br />

based on the most used predicates joining large tables and allow the <strong>DB2</strong> optimizer to use<br />

regrouping, predicate matching and expression derivation.<br />

Multi-dimensional applications can gain benefits by using MQTs, when queries have<br />

opportunities <strong>for</strong> regrouping.<br />

If you can identify these cases, the same MQT can be reused in many different queries. A<br />

good case is when a new table in the <strong>DB2</strong> work file as a result of join is scanned a large<br />

number of times in a nested loop join: MQTs can be indexed.<br />

The use of MQTs can potentially provide huge savings in a data warehouse environment. It is<br />

good <strong>for</strong> queries, but not <strong>for</strong> OLTP due to the extra cost <strong>for</strong> BIND.<br />

For large MQTs, remember to:<br />

► Use segmented table spaces because of the almost instantaneous mass delete in<br />

REFRESH TABLE.<br />

► Execute RUNSTATS after REFRESH <strong>for</strong> good access path selection; otherwise, <strong>DB2</strong> uses<br />

default or out-of-date statistics.<br />

Keep the number of MQTs <strong>for</strong> a base table down to an acceptable number to avoid the extra<br />

cost of BIND time due to the large number of MQTs eligible <strong>for</strong> query rewrite, as well as the<br />

processing necessary <strong>for</strong> the maintenance of MQTs. For a simple query the measured<br />

overhead is about 0.4 ms to examine each qualified MQT.<br />

When creating a user-maintained materialized query table, initially disable query optimization.<br />

Otherwise, <strong>DB2</strong> might automatically rewrite queries to use the empty materialized query<br />

table.<br />

3.3 Star join processing enhancements<br />

3.3.1 Star schema<br />

In this section we describe how, in <strong>DB2</strong> V8, the execution of star join is improved by:<br />

► Access path enhancements<br />

► Better estimates of the filtering effect of dimensions<br />

► Use of sparse indexes in cache <strong>for</strong> materialized snowflakes<br />

► Use of in-memory work files<br />

The star schema data model is often used in data warehouses, data marts and OLAP. The<br />

representation of a star schema is shown in Figure 3-15.<br />

Chapter 3. SQL per<strong>for</strong>mance 53

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

Saved successfully!

Ooh no, something went wrong!