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.

10.3.1 Index design <strong>for</strong> post-DSO access<br />

For each table not chosen to provide filtering be<strong>for</strong>e the DSO is joined, you must<br />

ensure that these tables have indexes that support the join and local filtering<br />

predicates. This will ensure efficient nested loop join per<strong>for</strong>mance <strong>for</strong> all tables.<br />

Given the following WHERE clause from one of the remaining tables from the<br />

DSO example:<br />

WHERE "/<strong>BI</strong>C/AZ<strong>OS</strong>ASALE00"."PROFIT_CTR" = "/<strong>BI</strong>0/SPROFIT_CTR"."PROFIT_CTR"<br />

AND "/<strong>BI</strong>0/SPROFIT_CTR"."SID" = 31<br />

The relevant columns from table /<strong>BI</strong>0/SPROFIT_CTR are PROFIT_CTR (join<br />

predicate) and SID (local predicate).<br />

For smaller master data tables (less than a few data pages) or master data<br />

tables with local predicates that provide very little filtering, it may be sufficient to<br />

ensure that an index exists on the join columns only. This provides the greatest<br />

degree of flexibility, especially since the local predicates are not going to<br />

significantly limit the number of data pages accessed.<br />

As the master data table becomes larger and the local predicates provide more<br />

filtering, it is important to create indexes that support both the local and join<br />

predicates. Local predicates are preferred as the leading index columns because<br />

they support this table accessed as the leading table accessed or non-leading in<br />

the table join sequence. Additionally, they allow frequency statistics to be<br />

collected on the local predicate column with default RUNSTATS. Both the local<br />

and join predicates should be included in the index because both columns<br />

provide filtering as part of the join.<br />

There<strong>for</strong>e, <strong>for</strong> each smaller table (a few pages) we recommend having an index<br />

that supports the join predicates. This is also true <strong>for</strong> larger tables with local<br />

predicates that provide minimal filtering. Larger tables with local filtering<br />

predicates should have indexes on local (equal and IN) followed by join<br />

predicates. If local predicates are range predicates, then these should appear<br />

after join columns in the index.<br />

The index recommendation <strong>for</strong> table /<strong>BI</strong>0/SPROFIT_CTR is shown in Table 10-4.<br />

Table 10-4 Index recommendation<br />

Column Reason<br />

SID Local (equal) filtering predicate<br />

PROFIT_CTR Filtering join predicate<br />

Chapter 10. Tips <strong>for</strong> SQL efficiency 223

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

Saved successfully!

Ooh no, something went wrong!