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.

3.8.2 Per<strong>for</strong>mance<br />

We show three examples.<br />

Example 3-10 shows passing a multiplier value.<br />

Example 3-10 User-defined table function (1/3)<br />

SELECT *<br />

FROM TABLE(TUDF(1) CARDINALITY MULTIPLIER 30) AS X;<br />

If the cardinality was specified to be 1 when TUDF was defined, <strong>DB2</strong> assumes that the<br />

expected number of rows to be returned is 30 (30 x 1) <strong>for</strong> this invocation of user-defined table<br />

function TUDF.<br />

Example 3-11 shows a different multiplier.<br />

Example 3-11 User-defined table function (2/3)<br />

SELECT R<br />

FROM TABLE(TUDF(2) CARDINALITY MULTIPLIER 0.3) AS X;<br />

If the cardinality was specified to be 100 when TUDF was defined, <strong>DB2</strong> assumes that the<br />

expected number of rows to be returned by TUDF is 30 (0.3 x 100).<br />

Example 3-12 shows passing an absolute value.<br />

Example 3-12 User-defined table function (3/3)<br />

SELECT R<br />

FROM TABLE(TUDF(3) CARDINALITY 30) AS X;<br />

<strong>DB2</strong> assumes that the expected number of rows to be returned by TUDF is 30, regardless of<br />

the value in the table function.<br />

For more details on the specification of CARDINALITY and CARDINALITY MULTIPLIER, see<br />

the table-UDF-cardinality-clause section in <strong>DB2</strong> <strong>UDB</strong> <strong>for</strong> z/<strong>OS</strong> <strong>Version</strong> 8 SQL Reference,<br />

SC18-7426.<br />

Table UDFs are driven by Content Manager in all members of the <strong>DB2</strong> family:<br />

► Content Manager uses Text In<strong>for</strong>mation Extender/Text Extender to per<strong>for</strong>m text search<br />

► Results from the table UDF are joined with base or other tables<br />

Measurements show the per<strong>for</strong>mance improvements <strong>for</strong> the table UDF as a result of:<br />

► Cardinality option:<br />

– User/Extender can specify the cardinality of the table UDF in SQL levels<br />

– Better access path selection<br />

► Table UDF block fetch support<br />

– Materialize the rows from a table UDF into a work file at UDF open statement<br />

► Table UDF join predicates become sortable<br />

– Retrofitted into V7 as PQ54042<br />

Figure 3-37 shows that specifying the cardinality option in SQL reduced both the elapsed and<br />

CPU time.<br />

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