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.8.3 Conclusion<br />

The measurements show that SQL statements using user-defined table functions can have<br />

per<strong>for</strong>mance improvement if using the cardinality option. Improvements apply to applications<br />

related to Content Management.<br />

3.8.4 Recommendations<br />

Specify cardinality to help the optimizer<br />

Make sure you have sufficient work file buffers and data sets across I/O devices, preferably<br />

with the Parallel Access Volume feature:<br />

► To avoid work file I/O contention, especially with other concurrently running jobs<br />

► For high table UDF cardinality<br />

3.9 ORDER BY in SELECT INTO with FETCH FIRST N ROWS<br />

This function allows you to specify ORDER BY in the SELECT INTO statement. It enables<br />

SELECT INTO to get the top rows based on a user-specified ordering. This means you can<br />

now issue a single SQL statement where in the past you had to issue a number of SQL<br />

statements or even write a program.<br />

An example would be:<br />

SELECT INTO.... ORDER BY ANNUAL_INCOME FETCH FIRST 1 ROW ONLY<br />

In this case up to 30% CPU time reduction can occur when compared to the<br />

Open/Fetch/Close sequence which was required in V7 when there were multiple rows to be<br />

selected, no sort was required. Generally, the entire result set is retrieved and sorted be<strong>for</strong>e<br />

the first row is returned.<br />

3.10 Trigger enhancements<br />

Prior to <strong>DB2</strong> V8:<br />

► The AFTER trigger causes the creation of a work file <strong>for</strong> old and new transition variables at<br />

each trigger invocation<br />

► Work files are always created, even when the WHEN condition evaluates to false<br />

With V8:<br />

► Avoid work file allocation if the WHEN condition evaluates to false<br />

► Avoid work file allocation if the transition table fits into 4 KB of working storage.<br />

Use of memory rather than of work files <strong>for</strong> small transition tables or variable<br />

► Work files are allocated if the transition table exceeds the working storage<br />

Example 3-13 shows the creation of the row trigger used in the measurements.<br />

Example 3-13 Sample row trigger creation<br />

CREATE TRIGGER ADD_AFT<br />

AFTER INSERT ON USRT001.EMPLOYEE<br />

REFERENCING NEW AS NROW<br />

FOR EACH ROW MODE <strong>DB2</strong>SQL<br />

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