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.

Query per<strong>for</strong>mance problem<br />

Lack of multi-column statistics can cause a bad access path and poor query per<strong>for</strong>mance<br />

when a table is referenced by two or more equal, range or BETWEEN predicates.<br />

The possibility of hitting this problem increases when:<br />

► The number of predicates referencing one table increases<br />

► The number of joined tables in a query increases<br />

Two, often complementary, <strong>DB2</strong> V8 functions help with this issue:<br />

► Collecting additional statistics<br />

► Relying on <strong>DB2</strong> V8 better filter factor estimation<br />

Additional statistics<br />

Collecting cardinality and multi-column distribution statistics and rebinding is the first step to<br />

solve the problem. The Statistics Advisor, of Visual Explain V8, can generate automatically<br />

the RUNSTATS statement <strong>for</strong> the query, after using the Analyze function <strong>for</strong> a multi-predicate<br />

SQL text. See 6.4, “RUNSTATS enhancements” on page 272. Visual Explain is discussed in<br />

3.15, “Visual Explain” on page 110 and 3.15.3, “Statistics Advisor” on page 116.<br />

Example 3-6 shows one SQL statement text used as input to Visual Explain. This is the old<br />

query 5 used to verify the <strong>DB2</strong> Catalog consistency, discussed in Chapter 9, “Installation and<br />

migration” on page 341.<br />

Example 3-6 SQL text <strong>for</strong> Visual Explain<br />

SELECT DBNAME, NAME FROM SYS<strong>IBM</strong>.SYSTABLESPACE TS<br />

WHERE NTABLES <br />

(SELECT COUNT(*) FROM SYS<strong>IBM</strong>.SYSTABLES TB<br />

WHERE TYPE IN ('T', 'X','M')<br />

AND TB.DBNAME = TS.DBNAME<br />

AND TB.TSNAME = TS.NAME<br />

AND TS.NAME 'SYSDEFLT');<br />

The query has one correlated subquery.<br />

The outer query scans the SYS<strong>IBM</strong>.SYSTABLESPACE table which has the indicated number<br />

of tables NTABLES different from the counts of tables in the inner query based on table<br />

SYS<strong>IBM</strong>.SYSTABLES. For each qualified row in the outer table, the inner query is<br />

re-executed. Table type = “X” specifies auxiliary table at the current server <strong>for</strong> storing LOB<br />

data.<br />

The Explain function in Visual Explain <strong>for</strong> the SQL text results in the graphic <strong>for</strong> the access<br />

path selected by <strong>DB2</strong> V8 in Figure 3-29.<br />

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