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.

Be<strong>for</strong>e the introduction of MQTs, <strong>DB2</strong> had to struggle through long data warehouse queries.<br />

And the DBA had to pre-elaborate complex SELECTs with lots of UNIONs and JOINS in<br />

order to create intermediate tables to be used by application people.<br />

Figure 3-60 shows the graph <strong>for</strong> the query in Figure 3-13 (no MQT).<br />

Figure 3-60 Explain without using an MQT table by Visual Explain<br />

<strong>DB2</strong> accesses an MQT the same way it accesses a base table with one exception: <strong>DB2</strong><br />

cannot use a direct fetch to access a materialized query table.<br />

When underlying data changes, <strong>DB2</strong> does not automatically refresh MQTs. To keep the MQT<br />

data current, you must issue a REFRESH TABLE statement if the table is system-maintained,<br />

or, if the materialized query table is user-maintained, you must issue INSERT, UPDATE, and<br />

DELETE statements as needed. To control the use of MQTs, use the CURRENT REFRESH<br />

AGE and CURRENT MAINTAINED TABLE TYPES FOR OPTIMIZATION special registers.<br />

An MQT node is labeled with the name of the MQT and is, by default, displayed as an<br />

upside-down trapezoid. The table's correlation name, creator name, or cardinality can also be<br />

displayed on the label. If the RUNSTATS utility has not collected statistics <strong>for</strong> the table, the<br />

node is outlined in red. If the optimizer uses the default value <strong>for</strong> the cardinality, the cardinality<br />

is marked as the default.<br />

On Figure 3-61 you can see the EXPLAIN graph generated by the VE of a query using the<br />

MQT table with the name MATPROC ID = 14 and Cardinality = 6.<br />

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