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.

stores the selected columns from each qualifying base row in the result DTT and scrolling is<br />

per<strong>for</strong>med on this temporary table. <strong>DB2</strong> deletes the result table when the cursor is closed.<br />

Dynamic scrollable cursors are new with <strong>DB2</strong> V8. Dynamic scrollable cursors do not<br />

materialize the result table. Instead, they scroll directly on the base table and are there<strong>for</strong>e<br />

sensitive to all committed inserts, updates, and deletes. Dynamic scrollable cursors are<br />

supported <strong>for</strong> the index scan and table space scan access paths. DPSIs can also support<br />

dynamic scrollable cursors. Dynamic scrollable cursors can also be used with row-level<br />

operations or rowset-level operations.<br />

3.12.1 Static scrollable cursor description<br />

Static scrollable cursors introduced in V7 allow scrolling backwards as well as <strong>for</strong>wards. They<br />

also provide the capability to place the cursor to an absolute position or a position relative to<br />

the current cursor. In terms of per<strong>for</strong>mance, when a static scrollable cursor is opened, the<br />

qualifying rows are copied to a <strong>DB2</strong>-declared temporary table, also commonly known as the<br />

result table. This result table has a fixed (static) number of qualifying rows. Per<strong>for</strong>mance<br />

impact is based upon the number of qualifying rows that must be copied from the base table<br />

to the temporary table. Once the qualifying rows are copied to the temporary table, scrolling is<br />

then per<strong>for</strong>med on this table in either the <strong>for</strong>ward or backward direction, sequentially or to a<br />

specific row. When the cursor is closed, <strong>DB2</strong> deletes the result table.<br />

Dynamic scrollable cursors generally do not employ the usage of a temporary table.<br />

There<strong>for</strong>e, the single most important per<strong>for</strong>mance difference between static scrollable cursors<br />

and dynamic scrollable cursors is the overhead in building the result table, maintaining a<br />

consistent relationship between the base and result tables with an updatable cursor, and<br />

deleting the result table at close cursor <strong>for</strong> static scrollable cursors.<br />

Sensitivity options <strong>for</strong> static scrollable cursors<br />

A static scrollable cursor can be sensitive or insensitive to update, and can be sensitive or<br />

insensitive to changes made by other applications or outside of the cursor. These can be<br />

specified in the DECLARE CURSOR statement and FETCH statement. Table 3-3 outlines the<br />

available combinations, whether the cursor is read only or updatable, and whether the cursor<br />

is sensitive to changes to the base table.<br />

Table 3-3 Static cursor declare and fetch specifications<br />

Specification<br />

on DECLARE<br />

Specification<br />

on FETCH<br />

92 <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><br />

Type of<br />

Cursor<br />

Comments<br />

Insensitive Insensitive Read-only Not aware of updates, deletes and inserts to<br />

base table<br />

<strong>DB2</strong> uses the predefined TEMP database and<br />

segmented table space to create your DTT and<br />

move in the results at execution time.<br />

Sensitive Insensitive Updatable Aware of own updates and deletes within the<br />

cursor.<br />

Changes by another agent are not visible to the<br />

cursor.<br />

Any inserts are not recognized.<br />

<strong>DB2</strong> uses the predefined TEMP database and<br />

segmented table space to create your DTT and<br />

move in the results at execution time.

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

Saved successfully!

Ooh no, something went wrong!