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.

3.4.1 New indexable predicates in V7<br />

PTF UQ61237 <strong>for</strong> APAR PQ54042 resolves a case of incorrect output resulting from SQL<br />

statements that contain a BETWEEN predicate. The type of BETWEEN predicate that may<br />

have this problem is:<br />

col BETWEEN col-expression AND col-expression<br />

Where “col” is a simple column and “col-expression” is any expression involving a column.<br />

In addition, BETWEEN predicates of the <strong>for</strong>m:<br />

T1.COL BETWEEN T2.COL1 AND T2.COL2<br />

can now be indexable when accessing the table on the left hand side of the BETWEEN<br />

keyword if the tables on the right hand side of the BETWEEN keyword have already been<br />

accessed.<br />

3.4.2 More stage 1 and indexable predicates in V8<br />

In V8, more predicates with mismatched data types and mismatched lengths can be applied<br />

by <strong>DB2</strong>. This allows some stage 2 predicates to become stage 1 predicates, and stage 1<br />

predicates allow more index usage, and it applies to both join and local predicates.<br />

The potential <strong>for</strong> per<strong>for</strong>mance improvement with no application change is very significant.<br />

Note that mismatched string data types in join became stage 1 in V6.<br />

Mismatched numeric types<br />

Figure 3-25 shows an example of a predicate using mismatched numeric types that is stage 2<br />

in V7 and becomes stage 1 and indexable in V8 NFM.<br />

In the example, the selection of rows from employee table has to scan the table space in V7<br />

because the predicate indicates salary defined as decimal (12,2) is compared to a host<br />

variable defined as floating point that is stage 2.<br />

The same predicate is stage 1 in V8 and it allows matching index scan to find the rows <strong>for</strong> the<br />

execution of the SQL.<br />

Example of mismatched numeric type<br />

employee ( name character (20),<br />

salary decimal (12,2),<br />

deptid character (3) );<br />

SELECT * FROM employee<br />

WHERE salary > :hv_float ;<br />

in V7<br />

Stage-2 predicate<br />

Table space scan<br />

Figure 3-25 Example of mismatched numeric types<br />

V8<br />

Stage-1 predicate<br />

salary indexable<br />

Chapter 3. SQL per<strong>for</strong>mance 67<br />

.

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

Saved successfully!

Ooh no, something went wrong!