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.

► Timestamp: 2004-11-15 13:44:36.771989 (RUNSTATS)<br />

► Explain time: 2004-11-19 14:56:24:34<br />

If we click the Index node (5) DSNPPH01, the in<strong>for</strong>mation about the index used to access<br />

SYSPLAN pops up: Fullkeycard of 61 and cluster ratio of 0.4918. The attribute side shows the<br />

number of leaf pages, number of levels, if the rows are clustered <strong>for</strong> this index, if the index is<br />

padded, and other in<strong>for</strong>mation.<br />

The index scan node (4) shows the number of input RIDs and output RIDs, scanned leaf<br />

pages, total filter factor, and number of matching columns <strong>for</strong> this scan.<br />

The fetch node shows a cardinality of 14. This is very interesting. The attribute of the fetch<br />

node shows:<br />

► Scanned rows: 61<br />

► Stage 1 predicate: PL. PLENTRIES=0. Filter factor: 0.459<br />

► Stage 1 returned rows: 28. If we calculate 61 * 0.459 = 27.999<br />

► Stage 2 predicate: NOT EXISTS(SELECT 1 FROM SYSDBRM WHERE<br />

SYSDBRM.PLNAME=PL.NAME); Filter factor: 0.5.<br />

► Stage 2 returned rows: 14<br />

For each entry in the index DSNPPH01 leaf page (no matching index scan) <strong>DB2</strong> has to go to<br />

the data portion to verify the predicate PL.PLENTRIES=0. PLENTRIES is the number of<br />

package list entries <strong>for</strong> the plan. The size of the row in SYSPLAN is 3613 bytes in a 4 KB<br />

page.<br />

Since this query is a correlated subquery, <strong>for</strong> each row in the outer table the inner query is<br />

re-executed. This subquery is an non-matching index-only scan, resulting in many scans to all<br />

leaf pages in the index PMSYSDBRM1 because the PLNAME is the second column of the<br />

index.<br />

So the largest impact comes from the time to scan all leaf pages <strong>for</strong> the entries in the index <strong>for</strong><br />

the table SYSDBRM. If the number of DBRMs is small, this can be a few pages, but if the<br />

catalog has a large number of DBRMs, <strong>for</strong> example, 20,000, and the index on columns<br />

PLCREATOR, PLNAME, has a key of 16 bytes, resulting in approximately 200 keys per page,<br />

there is a total of 100 leaf pages <strong>for</strong> each plan that has PLENTRIES=0.<br />

If there are 10,000 plans not using a package list, there are 10,000 scans of 100 pages.<br />

In this example we executed the query under Visual Explain and the output resulted in two<br />

rows.<br />

Let us take a look at the new Query 3, listed in Table 3-12.<br />

Table 3-12 Consistency Query 31 New<br />

The new Query<br />

SELECT NAME FROM SYS<strong>IBM</strong>.SYSPLAN<br />

WHERE PLENTRIES = 0<br />

AND NAME NOT IN<br />

(SELECT PLNAME FROM SYS<strong>IBM</strong>.SYSDBRM);<br />

The new query is a non-correlated query. In a non-correlated subquery case the subquery is<br />

executed only once and the result of the query is materialized in the work file. The validation<br />

of the clause NOT IN is made in the sorted work file.<br />

The optimizer uses the process (scan, sort, work file) to make the per<strong>for</strong>mance better as<br />

shown in Figure 3-48. This change makes a nice difference when we compare the CPU cost<br />

Chapter 3. SQL per<strong>for</strong>mance 115

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

Saved successfully!

Ooh no, something went wrong!