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.

Table 10-2 Indexing options<br />

Column Local<br />

or join<br />

AND "/<strong>BI</strong>C/AZ<strong>OS</strong>ASALE00"."ACCNT_ASGN" IN ('00', '01', '04', '06')<br />

AND "/<strong>BI</strong>C/AZ<strong>OS</strong>ASALE00"."CALMONTH" BETWEEN '200311' AND '200404'<br />

AND "/<strong>BI</strong>C/AZ<strong>OS</strong>ASALE00"."CURTYPE" = 'B0'<br />

For the non-leading tables in the join, local predicates and join predicates are<br />

treated equally from the perspective of the ability to match index columns. Equal<br />

and IN predicates must precede range (BETWEEN, LIKE, =)<br />

predicates in the index, however, since range predicates will stop the index<br />

matching, and subsequent predicates will be applied as index screening.<br />

Similarly, a second IN predicate will also <strong>for</strong>ce matching to stop (at the column<br />

immediately preceding the second IN list) and revert to index screening.<br />

There<strong>for</strong>e, where possible, priority should be given to equal predicates <strong>for</strong><br />

indexing.<br />

Whether local predicates appear be<strong>for</strong>e join predicates depends on whether the<br />

local predicates will always appear in the query. If so, then the preference is to<br />

order local equal and IN columns be<strong>for</strong>e join columns in the index. This allows<br />

these columns to be used as matching as the leading or non-leading table in a<br />

join.<br />

Also, local predicates as the leading columns will ensure that any matching<br />

access to this index (as leading or non-leading table) will be restricted to the<br />

bounds of the equal predicate, which can provide a better bufferpool hit ratio and<br />

exploitation of index lookaside.<br />

To improve flexibility of local predicates, an alternative is to partition by a<br />

commonly used local predicate. A good example is often a time-based column in<br />

a data warehouse environment. Data warehouses (including <strong>SAP</strong> <strong>BI</strong> DSO and<br />

InfoCubes) generally contain many months or years of data, but users often<br />

query only the most recent, thus making separation of current and historical<br />

(<strong>using</strong> partitioning) a wise choice.<br />

The indexing options <strong>for</strong> table /<strong>BI</strong>C/AZ<strong>OS</strong>ASALE00 are shown in Table 10-2.<br />

Operator Partition<br />

candidate<br />

Index<br />

column<br />

sequence<br />

CURTYPE Local = Possibly 1 Optional<br />

ACCT_ASGN Local IN No 2 Optional<br />

Mandatory/optional<br />

/<strong>BI</strong>C/ZMATLPLNT Join = No 3 Mandatory<br />

PLANT Join = No 4 Mandatory<br />

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

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

Saved successfully!

Ooh no, something went wrong!