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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

10.2 SQL efficiency <strong>for</strong> InfoCube<br />

Now let us take a look at SQL efficiency <strong>for</strong> InfoCube. We recommend a method<br />

to simplify the analysis of a query against an InfoCube. An example of <strong>using</strong> this<br />

method follows a general description.<br />

1. Analyze the joins and build a join graph.<br />

a. Ignore the SELECT list. We assume that all the columns that are selected<br />

are required. Note that we do not have much choice on this if the query is<br />

generated SQL. If it is user-written SQL, then double-check the SELECT<br />

list.<br />

b. Ignore the FROM clause. We assume that all the tables that are listed are<br />

required. Note that we do not have much choice on this if the query is<br />

generated SQL. If it is user-written SQL, then double-check the FROM list.<br />

c. Ignore the GROUP BY clause. The columns in the GROUP BY clause<br />

must be equal to or a superset of the columns in the SELECT list. Any<br />

column in the SELECT list that is not contained within a column function<br />

must be in the GROUP BY clause. Note that all the columns in the<br />

GROUP BY clause do not need to be in the SELECT list.<br />

d. Focus on the WHERE clause.<br />

i. For each join predicate, map the table join relationship.<br />

ii. Ignore the local predicates <strong>for</strong> now.<br />

iii. Check that all the tables in the FROM clause are accounted <strong>for</strong> in the<br />

join graph. This verifies that each table has at least one join predicate.<br />

2. Associate local predicates to their table by mapping each local predicate to<br />

the appropriate table on the join graph.<br />

3. Determine the filtering.<br />

Count the number of rows retrieved <strong>for</strong> each master data table, then each<br />

master data joined to its corresponding dimension, and finally joined to the<br />

facttable. Include the local predicates on the tables. This shows the effect of<br />

filtering of the dimension/snowflake against the facttable.<br />

4. Compare the filtering of the each of dimensions/snowflakes joined to the<br />

facttable. This data should show where the access path should start <strong>for</strong> the<br />

query and provide a method to compare with the actual access path seen <strong>for</strong><br />

the query.<br />

Let us look at an example of <strong>using</strong> this process to analyze a real-life customer<br />

query.<br />

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

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

Saved successfully!

Ooh no, something went wrong!