07.02.2013 Views

Best Practices for SAP BI using DB2 9 for z/OS - IBM Redbooks

Best Practices for SAP BI using DB2 9 for z/OS - IBM Redbooks

Best Practices for SAP BI using DB2 9 for z/OS - 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.

WHERE clause). The per<strong>for</strong>mance improvement can be gained only on a table<br />

with triggers defined. Otherwise, it will per<strong>for</strong>m as today. Moreover, it provides a<br />

statement commit option (IMMEDIATE option) <strong>for</strong> the statement that allows the<br />

truncate operation to become permanent (that is, cannot undo) and immediately<br />

makes deallocated space available <strong>for</strong> new, subsequent inserts in the same unit<br />

of work.<br />

<strong>SAP</strong> <strong>BI</strong> will use the TRUNCATE TABLE statement of <strong>DB2</strong> 9, but because <strong>BI</strong><br />

tables usually have no triggers, the per<strong>for</strong>mance is the same as the mass delete<br />

operation.<br />

4.6 FETCH FIRST n ROWS ONLY in subselects<br />

<strong>DB2</strong> 8 <strong>for</strong> z/<strong>OS</strong> disallows the FETCH FIRST n ROWS ONLY clause in a<br />

subselect. That is, one could write:<br />

SELECT * FROM T ORDER BY c1 FETCH FIRST n ROWS ONLY<br />

(specifying the clauses as part of select-statement), but one could not write:<br />

INSERT INTO any_table<br />

(SELECT * FROM T ORDER BY c1 FETCH FIRST n ROWS ONLY)<br />

(specifying the clauses within the subselect).<br />

<strong>SAP</strong> <strong>BI</strong> needs this feature to implement a more sophisticated algorithm of the<br />

so-called <strong>BI</strong> Selective Deletion <strong>for</strong> InfoCube and DSO data. Here selective<br />

means that the user can choose an arbitrary selection criteria <strong>for</strong> the data to be<br />

deleted. In this general case the data to be deleted can be distributed over all<br />

table partitions of a partitioned table, so that the deletion of whole partitions<br />

cannot be used.<br />

When deleting a huge amount of data rows from a fact or DSO table, it is better<br />

to separate this deletion in many small portions of delete transactions.<br />

Otherwise, you have one probably very long-running delete transaction, with the<br />

danger of a day-long or even longer rollback in the case the delete transaction<br />

has to be canceled <strong>for</strong> any purpose. This is a nightmare <strong>for</strong> every database<br />

administrator.<br />

With the <strong>DB2</strong> 9 feature of <strong>using</strong> FETCH FIRST n ROWS ONLY within a<br />

subselect, the portionwise deletion is implemented in the following way.<br />

The large delete operation is split up into multiple smaller units of work. In<br />

Example 4-2, assume that the primary key of table consists of the<br />

columns kf1, kf2, ..., kfn. is a placeholder <strong>for</strong> the WHERE<br />

Chapter 4. Benefits of <strong>DB2</strong> 9 <strong>for</strong> <strong>SAP</strong> <strong>BI</strong> 51

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

Saved successfully!

Ooh no, something went wrong!