Vous êtes sur la page 1sur 56

DB2 LUW for SAP BW Lab Exercises

DB2 LUW for SAP BW Lab Exercise Hand Book

WW DB2 SAP TECHNICAL ENABLEMENT AND SUPPORT TEAM

WW DB2 SAP Technical Enablement and Support Team

Page 1

DB2 LUW for SAP BW Lab Exercises

Exercise Overview
Unit 1 DB2 LUW Administration in General
1 1 1 1 1 1 Get familiar with DBACockpit Understand DB2 database Key Performance Indicators (KPIs) Understand DB2 configuration Get familiar with Single Table Analysis feature Buffer pool and table space maintenance Use db2look tool

Unit 2 BI Objects in DB2


7 7 7 7 7 7 7 7 7 7 7 7 System overview in Data Warehousing Workbench Find the database table name for a InfoCube Check Fact table storage parameters Schema Viewer for InfoCubes Fact table analysis Find the database table name for a DataStore Object Check ODS table storage parameters Check ODS table structure Find the database table name for a PSA table Check PSA table storage parameters Check PSA table structure Find the InfoObject and Master Data Tables

Unit 3 Scale out SAP BW database


19 19 19 19 19 19 19 Create new partition group Create new table spaces which are mapped to new data classes Create a new InfoArea and a new InfoCube that is stored in new table spaces Load data to the InfoCube Add a new partition Redistribute the InfoCube fact table to the new partition Drop a partition

Unit 4 BI Query Analysis


26 27 26 26 Run BI query through RSRT query monitor Use BI Query Visualizer to analyze the query Analyze query access plan Collect optimizer data for query performance analysis

Unit 5 MDC for SAP BW


30 31 32 33 34 Convert an existing fact table to MDC table Check Fact table storage parameters Run query against the new fact table Compare the query performance and analyze the new access plan Check BI parameters related to MDC usage

WW DB2 SAP Technical Enablement and Support Team

Page 2

DB2 LUW for SAP BW Lab Exercises Unit 6 Deep Compression for SAP BW
35 35 35 35 35 Compress an existing fact table Check new table size Run query against the new fact table Analyze the new access plan Check DB2 compression related BI parameter

Unit 7 BI Operations
36 37 38 39 40 Compress an InfoCube Run query against a compressed InfoCube Create an aggregate Check aggregate table structure and storage parameters Run query against an aggregated InfoCube

WW DB2 SAP Technical Enablement and Support Team

Page 3

DB2 LUW for SAP BW Lab Exercises

Unit 1 DB2 LUW Administration in General System ID : N4S Database server : n4shost System number : 42 1.1 Logon data User ID : bwuser Password : sapn4sadm Run transaction DBACockpit (or ST04), and found out the following KPIs: 1. buffer pool quality on database level and on each table space level? 2. package cache and catalog cache quality, any cache overflow? 3. any lock escalation and dead locks? 4. any sort overflow? Find out the following DB2 configuration information: 1. what is the value for the registry variable DB2_WORKLOAD? 2. what is the value for the database manager (DBM) configuration parameter INSTANCE_MEMORY? 3. what is the value for the database (DB) configuration parameter DATABASE_MEMORY? 4. what is the TCPIP port number used by db2 instance? check SVCENAME configuration parameter DBACockpit -> Space -> Single Table Analysis, type in Table name /BIC/FZSD_C01, hit Enter 1. whats the table size? How many rows (cardinality)? 2. when was the last time the table statistics was collected? 3. how many indexes have been defined? 4. check table structure, index structure 1. create a new buffer pool BP32K with 32K page size and 100 pages Note: due to a bug in DBACockpit -> Configuration -> Buffer Pools -> Add, we have to create this buffer pool from DB2 command line: db2 "create bufferpool bp32k size 100 pagesize 32k" 2. Add a table space myspace from DBACockpit, with automatic storage feature, 32K page size and assign BP32K to it 3. enable DIO by altering table space to NO FILE SYSTEM CACHING on DB2 command line, db2 "alter tablespace myspace no file system caching" 4. delete the tablespace myspace and the buffer pool BP32K from DBACockpit. 1. 1.6 Use db2look tool 2. Retrieve the current layout of the database: db2look -d n4s -l > db_layout.txt Retrieve the definition and statistics of a SAP BW specific table, e.g. /BIC/FZSD_C01: db2look -d n4s -u sapn4s -z SAPN4S -e -m -t "/BIC/FZSD_C01" > zsd_c01.txt

1.2 Understand DB2 database Key Performance Indicators (KPIs)

1.3 Understand DB2 configuration

1.4 Get familiar with Single Table Analysis feature

1.5 Buffer Pool and Table space maintenance

WW DB2 SAP Technical Enablement and Support Team

Page 4

DB2 LUW for SAP BW Lab Exercises

Unit 2 BI Objects in DB2 Run transaction RSA1: Data Warehouse Workbench On the left navigation panel, select Modelling InfoProvider

benchmark

This will give you an over view of which InfoProviders will be used in the lab.

2.1 System overview

2.2 Find the database table name for a InfoCube

Run transaction RSA1 Modeling InfoProvider Select benchmark Select Benchmarkcube and right-click Select Manage Select Contents tab Select button Fact Table Table name is shown in header line.

Run transaction SE14. Enter table name: /BIC/FZSD_C01

Edit

2.3 Check Fact table storage parameters

On this screen, you can use Indexes button to see all indexes defined on this fact table, use Storage Parameters button to check DB2 specific storage parameters, use Check button to verify the consistency between SAP data dictionary (DDIC) and physical database table.

WW DB2 SAP Technical Enablement and Support Team

Page 5

DB2 LUW for SAP BW Lab Exercises

To check the table structure use button Storage Parameter. From here you can find the partitioning key definition, and which index is defined as clustering index.

2.4 Check storage parameter

WW DB2 SAP Technical Enablement and Support Team

Page 6

DB2 LUW for SAP BW Lab Exercises

Run transaction LISTSCHEMA. Enter Info Cube name: ZSD_C01

Execute

The extended star schema for this InfoCube, including fact table, all dimension tables and master data tables, are displayed.

2.5 Schema Viewer for InfoCubes

Run transaction DBACockpit, go to Space /BIC/FZSD_C01 and hit Enter

Single Table Analysis, enter table name

2.6 Fact table analysis

Check table and index statistics, table and index structure, etc.

Write down the Total Table Size, Total Index Size and No. of Pages with Data to the Work Sheet on the final page of this hand book.

WW DB2 SAP Technical Enablement and Support Team

Page 7

DB2 LUW for SAP BW Lab Exercises


Run transaction RSA1 Modeling InfoProvider Select benchmark odsbench and right-click Select Manage Select Contents tab: 2.7 Find the database table name for a DataStore Object Select

Select button New Data ODS activation queue table name is shown in heading: /BIC/AODSBENCH40 Select button Active Data ODS active table name is shown in heading: /BIC/AODSBENCH00 Select button Change Log ODS change log table name is shown in heading: /BIC/B0000002000 In SE14, enter table name /BIC/AODSBENCH40, /BIC/AODSBENCH00, and /BIC/B0000002000 Find out their partitioning keys, indexes, etc. In DBACockpit -> Space -> Single Table Analysis, enter table name /BIC/AODSBENCH40 and /BIC/AODSBENCH00 Find out their table and index structures, statistics, etc. In order to find out the PSA table name, go to SE16, enter table name RSTSODS, click Enter. On the Data Browser screen, enter ZBENCH* in the field ODSNAME, click Execute button.

2.8 Check ODS table storage parameters 2.9 Check ODS table structure

2.10 Find the database table name for a PSA table

One record is found:

WW DB2 SAP Technical Enablement and Support Team

Page 8

DB2 LUW for SAP BW Lab Exercises

From here we can see the PSA table name is /BIC/B0000020000. 2.11 Check PSA table storage parameters 2.12 Check PSA table structure

In SE14, enter table name /BIC/B0000020000, find out their partitioning keys and index definition. In DBACockpit -> Space -> Single Table Analysis, enter table name /BIC/B0000020000 Find out their table and index structures, statistics, etc. Run transaction RSA1 signed Characteristics Modeling InfoObjects Unassigned Nodes UnasSearch for Customer Number and double click.

2.13 Find the InfoObject and Master Data Tables

What master data tables have been created for InfoObject 0CUSTOMER? Write down the SID table name, and other master table names. Use SE14 and Single Table Analysis to check each table. You can also use SE16 to display table contents.

WW DB2 SAP Technical Enablement and Support Team

Page 9

DB2 LUW for SAP BW Lab Exercises

Unit 3 Scaling out SAP BW database Prerequisites: There is a bug in this version of the SAP/DB2 Test Drive DVD, which causes the BI Data Distribution Wizard to run under a userid with insufficient authority to alter tablespaces. The work around is to grant sapn4s SYSADM authority, by running the following command as root user: usermod -g dbn4sadm sapn4s Preparation for scaling out database: 3.1 Create a new database partition group 1. In the SAP GUI, open transaction dbacockpit and click Configuration -> Database Partition Groups. Click the Add button, and enter NGRP_FACT_NEW for the name, then click the Add button at the top of the screen and confirm the creation. By default, this new partition group will include all partitions available. At this time, there is only one partition partition 0. Click Space -> Tablespaces to view the list of tablespaces. Click the Add button, and enter NEW#FACTD as the tablespace name, and select NGRP_FACT_NEW as the partition group and 16K page size. Ensure AutoStorage is selected and then click the Add button at the top of the screen to create this new tablespace; repeat the same steps to create another table space NEW#FACTI, make sure to select NGRP_FACT_NEW as the partition group and 16K pagesize. Click Configuration -> Data Classes to add a new data class. Click the Add button, and enter ZFACT as the Data Class name with the description New Fact Tables, and select NEW#FACTD as the Data Tablespace, NEW#FACTI as the Index Tablespace. Then click the Add button to create this data class.

3.2 Create new table spaces

2.

3.3 Create a new data class

3.

WW DB2 SAP Technical Enablement and Support Team

Page 10

DB2 LUW for SAP BW Lab Exercises


3.4 Create a new InfoArea Run transaction RSA1 Modeling InfoProvider Right click on the header of the column InfoProvider, and choose Create InfoArea.

3.5 Create a new InfoCube by copying the existing InfoCube ZSD_C01

Right click on the My InfoArea, and select Create InfoCube. On the Edit InfoCube pop-up window, change the InfoCube name to ZSD_C02, enter the description, select the Copy From cube as ZSD_C01, and click Create button.

Back on the DW workbench screen, go to Extra tain DB-Storage Parameters,

DB Performance

Main-

On the Maintain Storage Parameters screen, change the Data Type of both InfoCube and Aggregate to the new data class ZFACT and click on Continue button. *Note* if you dont see ZFACT being displayed in the drop-down list, you might have to run a transaction /$SYNC to refresh the SAP table buffer. It seems to be an error in buffer synchronization for table DDART. On the DW workbench, click Activate button to activate the new InfoCube. Click Save button to save all changes. You will notice the InfoCube object

WW DB2 SAP Technical Enablement and Support Team

Page 11

DB2 LUW for SAP BW Lab Exercises


status is changed from Active to Inactive after its saved. You need to reactivate the InfoCube by clicking Activate button again. Run transaction RSA1 Modeling DataSources On DataSource benchmark zbench, right click, and select Copy Enter Targe DataSource name ZBENCH_ZSD_C02, and select Source System BENCH, then click OK button

3.6 Create a new DataSource

On the Change DataSource ZBENC_ZSD_C02(BENCH) screen, under General Info tab, change all descriptions to zbench_zsd_c02:

under Extraction tab, select the Adapter Load Text-Type File from Application Server, and enter te File Name

WW DB2 SAP Technical Enablement and Support Team

Page 12

DB2 LUW for SAP BW Lab Exercises


/usr/sap/trans/bwbench/data/sd_c01_trans1.txt:

Go to the Proposal tab. On the rows for column Field Name with values VERSION, SOLD_TO, MATERIAL and BASE_UOM, change corresponding Format column value to External. Click Activate button to activate this DataSource. Accept the prompt of warning message. You can test the DataSource by using Read Preview Data under the Preview tab. On the newly created DataSource zbench_zsd_c02, right click, choose Create Transformation On the Create Transformation screen, select Object Type InfoCube and enter the Name ZSD_C02. Hit Enter.

3.7 Create Transformation

On the Transformation Creat screen, if you hit Ctrl-F2, or choose menu item Transformation Check, you will see the Log Display screen which shows a number of error messages.

WW DB2 SAP Technical Enablement and Support Team

Page 13

DB2 LUW for SAP BW Lab Exercises

This is because these target fields need to be associated with either a unit or a currency. On the field mapping window, right click on the link that leads to one of these target field, e.g. OCRMEM_CST, select Rule Details.

On the Rule Details screen, use the drop-down list for the field Source Currency to select STAT_CURR for the Source Currency, then click on button Transfer Values.

WW DB2 SAP Technical Enablement and Support Team

Page 14

DB2 LUW for SAP BW Lab Exercises

For the target fields that require a Source Unit, select BASE_UOM as the Source Unit. Repeat this step for every target field that requires either a Source Currency or a Source Unit, until Ctrl-F2 check returns no error (you can ignore three warning messages regarding 0CALMONTH, etc.) Click on Activate button to activate this Transformation. 3.8 Create InfoPackage On the newly created DataSource zbench_zsd_c02, right click, choose Create InfoPackage On the Create InfoPackage screen, enter the description InfoPackage for trans1 data file

Click on Save button.

WW DB2 SAP Technical Enablement and Support Team

Page 15

DB2 LUW for SAP BW Lab Exercises


3.9 Load data to PSA Double click on the newly created InfoPackage, choose Schedule tab, and click Start button to Start Data Load Immediately. You can use SM37 in another SAP GUI window to monitor the job execution. (If you click on Job(s) button on the InfoPackage screen, you need to change the job name from BI_BTCH* to BI_REQ*. ) On the newly created DataSource zbench_zsd_c02, right click, choose Create Data Transfer Process On the Creation of Data Transfer Process screen, enter the name of the DTP ZBENCH_ZSD_C02, and then choose the Target of DTP Object Type InfoCube and Name ZSD_C02. Click Coutinue button.

3.10 Create a Data Transfer Process (DTP)

On the Creation of Data Transfer Process window, click Activate button to activate this DTP. On the Display Data Transfer Process screen, choose Execute tab, and click on Execute in the Background button, 3.11 Load data to the InfoCube ZSD_C02 Click Yes to the question Do you want to display the request monitor?. On the Data Transfer Process monitor screen, click Refresh button to check job status until the job is completed. Run transaction DBACockpit Space Single Table Analysis, Enter table name /BIC/FZSD_C02, hit Enter Click button RUNSTATS in Dialog, after the runstats finishes, you should see the table Cardinality is 13640. 3.12 Check ZSD_C02 Fact table

3.13 Add a new partition

Before adding a partition, check the current partition configuration:

WW DB2 SAP Technical Enablement and Support Team

Page 16

DB2 LUW for SAP BW Lab Exercises


n4shost:db2n4s 51> cat db2/db2n4s/sqllib/db2nodes.cfg 0 n4shost 0 This shows currently there is only one partition. Before adding a new partition, we should log off SAP GUI and stop SAP first.
n4shost:n4sadm 52> stopsap

Make sure DB2 instance is stopped. Otherwise you could force to stop DB2 instance:
n4shost:n4sadm 52> db2stop force

Then, open a new terminal window under user root, go to the directory /storage/sapinst, and launch sapinst program:
n4shost:~ # cd /storage/sapinst n4shost:/storage/sapinst # ./sapinst

On sapinst screen, select the service SAP NetWeaver 7.0 Support Release 3 -> Software Life-Cycle Options -> Database Tools -> IBM DB2 for Linux, UNIX, and Windows -> Additional Database Partitions.

Click on Next button. On the following sapinst screen, enter the corresponding

WW DB2 SAP Technical Enablement and Support Team

Page 17

DB2 LUW for SAP BW Lab Exercises


input values for:
Profile Directory = /sapmnt/N4S/profile Connect User ABAP = sapn4s Password of SAP System Administrator = passw0rd Password of Database Administrator = passw0rd Password of ABAP Connect User = passw0rd Number of Additional Partitions = 1 Database Memory [MB] = 1000

Click Next button on the Parameter Summary screen, and the spainst starts to run. At the end, you should receive the following screen saying Additional Database Partitions has been completed successfully.. Click OK to exit sapinst screen.

Now you can check the current partition configuration:


n4shost:~ # su - db2n4s n4shost:db2n4s 51> cat /db2/db2n4s/sqllib/db2nodes.cfg 0 n4shost 0 1 n4shost 1

This shows the partition 1 has been added. After the partition 1 has been added, we need to change some configuration parameter values in order to run the work loads in the following lab exercises.
n4shost:db2n4s 53> cd /storage/scripts n4shost:db2n4s 55> db2 -tvf update_db_cfg_node1.clp !mkdir /db2/N4S/log_dir/NODE0001 mkdir: cannot create directory `/db2/N4S/log_dir/NODE0001': File exists update dbm cfg using instance_memory 250000

WW DB2 SAP Technical Enablement and Support Team

Page 18

DB2 LUW for SAP BW Lab Exercises


DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed successfully. alter bufferpool ibmdefaultbp size 8000 AUTOMATIC DB20000I The SQL command completed successfully. update db cfg for n4s using SORTHEAP 128 AUTOMATIC SHEAPTHRES_SHR AUTOMATIC LOCKLIST 1200 AUTOMATIC MAXLOCKS AUTOMATIC PCKCACHESZ 20000 AUTOMATIC DATABASE_MEMORY AUTOMATIC SELF_TUNING_MEM OFF CATALOGCACHE_SZ 2560 LOGBUFSZ 1024 DLCHKTIME 300000 LOGFILSIZ 16380 LOGPRIMARY 3 LOGSECOND 40 NEWLOGPATH /db2/N4S/log_dir BLK_LOG_DSK_FUL YES AUTO_STMT_STATS ON DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. SQL1363W One or more of the parameters submitted for immediate modification were not changed dynamically. For these configuration parameters, all applications must disconnect from this database before the changes become effective. terminate DB20000I The TERMINATE command completed successfully.

n4shost:db2n4s 56> db2stop 01/27/2009 13:18:40 successful. 01/27/2009 13:18:45 successful. SQL1064N DB2STOP processing was successful. 1 0 SQL1064N DB2STOP processing was 0 0 SQL1064N DB2STOP processing was

We are going to restart SAP system as user n4sadm. First of all, since NW07 SR3 remove the environment variable DB2DB6EKEY, we need to regenerate the user password file as below:
n4shost:n4sadm 65> dscdb6up -create passw0rd passw0rd password file '/usr/sap/N4S/SYS/global/dscdb6.conf' successfully written

Now restart SAP:


n4shost:n4sadm 52> startsap

Because the additional partition will need to use additional resource (CPU and memory), you might notice that the SAP system becomes slower than before.

WW DB2 SAP Technical Enablement and Support Team

Page 19

DB2 LUW for SAP BW Lab Exercises


3.14 Check current F fact table data distribution Firstly, lets check the current data distribution of the fact table /BIC/FZSD_C02. Log on SAP GUI with user bwuser. Goto DBACockpit -> Diagnostics -> SQL Commands, enter the following SELECT statement:
select dbpartitionnum(key_zsd_c02p) as partitionnum, count(*) from "/BIC/FZSD_C02" group by dbpartitionnum(key_zsd_c02p)

the following result returned, which means all 13640 records in this fact table are located in partition 0.
----------- ----------0 13640 1 record(s) selected.

3.15 Redistribute the existing table data to the new partition

Goto DBACockpit -> Wizards -> BI Data Distribution, click continue to begin. 1. Add partition 1 to the NGRP_FACT_NEW partition group and click continue. 2. Accept the default location for the temporary tablespace and click continue again. 3. Check Start Immediately, and then click continue. 4. Review the redistribution procedure summary and then click execute to start the redistribution process. This will run the script to create a system temporary tablespace container on the new partition, add the new partition into the partition group, and then redistribute the data to all existing and new partitions. You can go to Jobs -> DBA Log or SM37 to view the job log. After the job is completed successfully, check the new data distribution. Goto DBACockpit -> Diagnostics -> SQL Commands, enter the following SELECT statement:
select dbpartitionnum(key_zsd_c02p) as partitionnum, count(*) from "/BIC/FZSD_C02" group by dbpartitionnum(key_zsd_c02p)

3.16 Check new F fact table data distribution

It should return the result similar to below:


----------- ----------0 6896 1 6744 2 record(s) selected. This result indicates that total 13640 records have been more or less evenly distributed to two partitions 0 and 1. Keep in mind, the distribution might not be exactly even, but should not be skewed.

WW DB2 SAP Technical Enablement and Support Team

Page 20

DB2 LUW for SAP BW Lab Exercises

3.17 Remove the newly added partition from the partition group

The following steps show how to remove a partition. Before we can remove the partition 1, we have to move the data located in partition 1 to other partitions. For this, we can use the BI Data Distribution wizard again, to remove partition 1 from the partition group NGRP_FACT_NEW.

3.18 Redistribute the data back across the remaining partitions in the partition group

Click the Yellow up-arrow to exit the dbacockpit completely, and then return back into the dbacockpit, to the BI Data Distribution Wizard, click continue 1. remove the partition 1 from the NGRP_FACT_NEW partition group 2. accept the defaults on the next two screens and just click continue. 3. check Start Immediate, and then click continue one last time. You can go to Jobs -> DBA Log or SM37 to view the job log. You can now verify the data has been redistributed back to partition 0 only. Goto DBACockpit -> Diagnostics -> SQL Commands, enter the following SELECT statement:
n4shost:1> select dbpartitionnum(key_zsd_c02p) as partitionnum, count(*) from "/BIC/FZSD_C02" group by dbpartitionnum(key_zsd_c02p) ----------- ----------0 13640 1 record(s) selected.

3.19 Remove the partition from the database manager

Dropping the partition from the database manager cannot be done from within SAP. Once the preceding redistribute finishes, logon to n4shost as db2n4s, and run the following command to verify which partitions are still in use by the database: db2 drop dbpartitionnum verify Since you have previously removed your new partition from all partition groups and redistributed the data off of that partition, you should not see your new partition in this list. Completely logoff of SAP GUI, and run stopsap as n4sadm to stop SAP on the server. This prevents the SAP work processes from reconnecting to the database and causing problems while DB2 is dropping the partition. Then, switch to the db2n4s userid, and run the following command, to drop the partition from the database manager: db2stop drop dbpartitionnum 1 Again, cat /db2/db2n4s/sqllib/db2nodes.cfg, to verify that the partition has been removed, and then run startsap as the n4sadm userid, to restart SAP and DB2.

3.20 Confirm the partition removal and data distribution, and restart sap

WW DB2 SAP Technical Enablement and Support Team

Page 21

DB2 LUW for SAP BW Lab Exercises

Unit 4 BI Query Analysis In DBACockpit -> Performance -> SQL Cache, Set Selection Criteria Average Execution Time >= 1000 ms, Sort statements by Avg. Execution Time, pick an expensive statement and click on Ex4.1 Query plain button to display its access plan. Analysis in DBACockpit How is table accessed, by table scan or index access? Whats the estimated total cost? Run transaction RSRT, enter Query Name ZSD_C01/BENCHMARK_QUERY_2, click on Execute + Debug, check flags Do not use cache and Display statistics data (under Others section), hit Continue button. After the query results are displayed press Back button in the toolbar of the result window, the runtime statistics of the query is displayed.

4.2 BI Query Monitor

Question: how much time was spent in the database (Data Manager) and how much time was spent in the SAP Application Server (total time spent on all OLAP events)?

Write down the Duration of Data Manager to the Work Sheet on the final page of this hand book.
Run transaction RSRT, enter Query Name ZSD_C01/BENCHMARK_QUERY_2, click on Execute + Debug, 4.3 Check SQL Trace and access plan check flags Display SQL/BIA Query (under Data Manager section), hit Continue button. Firstly you will see the SQL statement display window, review the SQL statement.

WW DB2 SAP Technical Enablement and Support Team

Page 22

DB2 LUW for SAP BW Lab Exercises

From the above SQL statement, you can tell it is selecting data from F fact table joined with dimension tables for dimension T, U, 13 (sales org) and P where CALMONTH is between 200001 and 200012 and SALESORG is equal to 83, returning summarized column INCORDVAL (total incoming order value), INVCD_QTY (total invoiced quantity) and INVCD_VAL (total invoiced value) that are grouped by sales division and calendar year/month.

On this window, click on SQL Query Visualizer button

, you will get the Query

WW DB2 SAP Technical Enablement and Support Team

Page 23

DB2 LUW for SAP BW Lab Exercises


Visualization screen. Further click on the Schema View Block Query Block 0 bar, you will see the graphical view of the query structure. Click on one of the tables, e.g. /BIC/DZSD_C01T table, you will see the details about this table as well as the table join with the fact table.

Questions: 1. what are the local conditions applied to this table? What selectivity can you get when applying these conditions on this table? 2. how many number of rows in this table? 3. whats the estimated number of output rows? 4. what condition is used to join this table with the fact table?

Open another SAP GUI window and activate ST05 SQL trace; then click on back button on the tool bar of SQL screen to complete the query execution; deactivate ST05 trace. Display ST05 SQL Trace, locate the SQL-Statements that correspond to the query in the RSRT SQL window (obj. name = /BIC/FZSD_C01). Explain this SQL statements from within the ST05 trace (move the cursor on the statement text first, then click on Explain button)

WW DB2 SAP Technical Enablement and Support Team

Page 24

DB2 LUW for SAP BW Lab Exercises

On the Display Execution Plan for SQL Statement window, you get the access plan. Click on the Tree Info button, you will see the number of rows returned, total cost and I/O cost of each operation. Questions: 1. What is the name of the fact table? 2. Which dimension table is joined firstly to the fact table, what type of join? 3. What method is used to access the fact table? If it is an index access, what is the index being used? 4. What is the total cost of this access plan? 5. How many rows will be returned by this query according to the access plan?

4.4 check SQL Cache

Another way to check the query access plan, without using ST05 trace, is to check DB2 SQL cache (Package cache) directly.

WW DB2 SAP Technical Enablement and Support Team

Page 25

DB2 LUW for SAP BW Lab Exercises

In another SAP GUI window, go to DBACockpit -> Performance -> SQL Cache. On the Selection Criteria window, remove 100 from the Executions field, and enter the SELECT*FZSD_C01* in the SQL Text field. The following statement execution result is returned:

Write down the Avg. Execution time, Buffer Quality, Rows Read, SQL Sorts and the total Estimated Costs to the Work Sheet on the final page of this hand book.
*Note* For more accurate comparison, especially to demonstrate the disk I/O cost saving by using MDC feature in the next exercise, you need to run the query in a cold buffer pool, which means the table data should not have been cached in the buffer pool. This will require comparing the result on the first query execution on a newly started system. Therefore you might want to stop and restart your SAP system before running the query. Double click on the statement, or click on Explain button, you will get the access plan of this statement. In the case of query performance problem, and you want to open an SAP OSS message, you need to collect related diagnostics data for this query. On the Display Execution Plan screen, click on Collect button, which will allow you to download query related data, such as database configuration parameters, table and index definitions and statistics, detailed access plan, etc. into respective files.

4.5 Collect diagnostics data for query performance problem

WW DB2 SAP Technical Enablement and Support Team

Page 26

DB2 LUW for SAP BW Lab Exercises


For deeper analysis, you can use db2support tool to collect much more detailed data, which will allow IBM DB2 support to mimic your runtime environment and reproduce the problem on their test system. Steps: 1.

Save SQL statement in a text file. From the Execution Plan screen, you can click on Edit button, which will open a Edit SQL Statement window, you could use one of the following ways to create a statement text file on the database : a. select the entire statement text, hit CTRL+C to copy the text to the clipboard, then on the DB2 command window (in user db2n4s) on the database server, use vi editor to create a file query2.sql, paste the statement text to vi, add an ; at the end of the statement, and save this file; b. you can save the file locally by using the Save as local file button. Then move the file from local to the database server in a directory that can be accessed by user db2n4s (e.g. /db2/N4S/db2dump). You also need to edit the file by adding ; at the end.

4.6 use db2support tool to collect detailed query performance data

2.

On the database server, in the db2n4s command window, enter the following command:

n4shost:db2n4s 176> db2support /db2/N4S/db2dump d n4s -sf query2.sql curschema sapn4s

Once the db2support.zip file is generated, download it to the local server, and check what data has been collected.

WW DB2 SAP Technical Enablement and Support Team

Page 27

DB2 LUW for SAP BW Lab Exercises


Or use the following command to unzip the file on the server:
n4shost:db2n4s 193> unzip db2support.zip

WW DB2 SAP Technical Enablement and Support Team

Page 28

DB2 LUW for SAP BW Lab Exercises

Unit 5 MDC for SAP BW Run transaction RSA1: Modelling click InfoCube Benchmarkcube InfoProvider Select benchmark RightAdditional Functions Reclustering

5.1 Change/defin e MDC settings for an existing InfoCube

Click button Initialize

5.2 Confirm that a recent backup was done before activating the changes

The system is asking if a database backup was done. You must answer the pop-up with Yes. Otherwise, you cannot activate the changes. Reclustering entails copying data from the original table into a shadow MDC table. Therefore a valid backup before the changes is required. In this exercise, we will skip the database backup.

Select Multi-Dimensional Clustering

Confirm selection

5.3 Select clustering type

WW DB2 SAP Technical Enablement and Support Team

Page 29

DB2 LUW for SAP BW Lab Exercises

5.4 Select the correct number of MDC columns

The default setting for the number of MDC columns is 3. If you select more than three columns (excluding Package Dimension), the system displays an error pop-up. Choosing too many columns will probably result in many half empty MDC cells allocated. By default, the time dimension SID_0CALMONTH is automatically selected as the first MDC dimension. Check Package Dimension on F Fact Table. A dimension on Package number will help to improve BW compression function. Also enter 2 on line ZSD_C013 Sales Area to define it as the second MDC dimension. Check Execute Space Check.

5.5 Choose MDC dimension columns among InfoCube dimension columns, and define the sequence number of MDC dimension

Click Continue button, and receive the following space check result:

WW DB2 SAP Technical Enablement and Support Team

Page 30

DB2 LUW for SAP BW Lab Exercises

The Space Check result is displayed in red colour, which means over 50% (Number of free pages 159180 / Number of pages that can be allocated 318360) of table space will be wasted. Further looking at the result, you see that the Number of different values in MDC dimension KEY_ZSD_C013 (Sales Area) is 64203, which is too great, compared to the other two MDC dimension columns on Package Dimension (12) and CALMONTH (132). Therefore Sales Area is not a good candidate for MDC dimension, and we need to remove the second MDC dimension on Sales Area. Click on Cancel button, go back to previous MDC definition screen, remove 2 from the line Sales Area, and leave Package Dimension and Calendar Month as MDC dimension columns. Click Continue button again, and display the new space check result:

WW DB2 SAP Technical Enablement and Support Team

Page 31

DB2 LUW for SAP BW Lab Exercises


This time the space check result is displayed in green colour, because the potential wasted space is less than 30% (Number of free pages 55 / Number of pages that can be allocated 1848 = 2.9%) Click Continue button. New request created confirmation. Click on Continue button.

5.6 Confirm request

Start re-cluster job in background. Select Immediate options for the background job, then click Save icon. Going back to Reclustering of InfoProviders screen, click on Monitor button. On the Monitor Requests screen, click on Refresh button until you see the status becomes green.

5.7 Schedule re-cluster job in batch

You can also use SM37 to check the background job status. Run transaction SE14. Enter table name: /BIC/FZSD_C01 5.8 Check storage parameter Edit

To check the table structure use button Storage Parameter. The clause Organize by Dimensions is used to define a MDC dimension. In this case, two MDC dimensions are defined: KEY_ZSD_C01P and SID_0CALMONTH.

WW DB2 SAP Technical Enablement and Support Team

Page 32

DB2 LUW for SAP BW Lab Exercises

Run transaction DBACockpit, go to Space /BIC/FZSD_C01 and hit Enter.

Single Table Analysis, enter table name

5.9 Fact Table Analysis

Write down the Total Table Size, Total Index Size and No. of Pages with Data to the Work Sheet on the final page of this hand book.
Comparison of the table size before and after the table is converted to MDC. You should notice that the total table size has increased, and in the mean time, the total index size has decreased because of using block index.

Also check the Index Structures, in which you should find

WW DB2 SAP Technical Enablement and Support Team

Page 33

DB2 LUW for SAP BW Lab Exercises


1. 2. 3. A composite Block Index SQL080104193459110 has been defined on both columns KEY_ZSD_C01P and SID_0CALMONTH. A dimension Block Index SQL080104193459220 has been defined on column SID_0CALMONTH. A dimension Block Index SQL080104193459240 has been defined on column KEY_ZSD_C01P.

All MDC block indexes are generated by the system and therefore start with SQL<number>. The index name generated on your system might differ. All regular RID indexes are user defined and follow the SAP naming convention for indexes: <Table Name>~<INDEX-NUMBER>, e.g. /BIC/FZSD_C01~020. Run transaction RSRT, enter Query Name ZSD_C01/BENCHMARK_QUERY_2, click on Execute + Debug, check flags Do not use cache and Display statistics data (under Others section), hit Continue button. After the query results are displayed press Back button in the toolbar of the result window, the runtime statistics of the query is displayed. 5.10 Run BI query again and verify the performance improvement after the fact table is converted to MDC. Comparing the result to 4.2

Question: how much time is spent in the database (Data Manager) this time?

Write down the Duration of Data Manager to the Work Sheet on the final page of this hand book.
In another SAP GUI window, go to DBACockpit -> Performance -> SQL Cache. On the Selection Criteria window, remove 100 from the Execution field, and enter the SELECT*FZSD_C01* in the SQL Text field. The following statement execution result is returned:

5.11 Check query performance and access plan

WW DB2 SAP Technical Enablement and Support Team

Page 34

DB2 LUW for SAP BW Lab Exercises


Double click on the statement, or click on the Explain button, you can get the following access plan:

Questions: 1. What method is used to access the fact table? If it is an index access, what is the index being used? Hint now it is using MDC block index based on CALMONTH dimension column. Which dimension table is joined firstly to the fact table, what type of join? What is the total cost of this access plan? Compared this cost with the result from the exercise 4.3.

2. 3.

Write down the Avg. Execution time, Buffer Quality, Rows Read, SQL Sorts and the total Estimated Costs to the Work Sheet on the final page of this hand book.
*Note* For more accurate comparison, especially to demonstrate the disk I/O cost saving by using MDC feature, you need to run the query in a cold buffer pool, which means the table data should not have been cached in the buffer pool. This will require comparing the result on the first query run on a newly started system. Therefore you might want to stop and restart your SAP system before running the query. As you can tell, the query time is much faster after the fact table has been converted to MDC table. And the access plan indicates that the block index defined on

WW DB2 SAP Technical Enablement and Support Team

Page 35

DB2 LUW for SAP BW Lab Exercises


SID_0CALMONTH is used to select rows on the fact table. Run program SAP_RSADMIN_MAINTAIN in transaction SA38. Enter DB6_MDC_FOR_PSA in the OBJECT field, and YES in the VALUE field, choose INSERT, then click on Execute button.

5.12 Change settings in table RSADMIN.

Run transaction SE16 - Data Browser Browse table: RSADMIN Restrict values in field OBJECT to DB6*

5.13 Check settings in table RSADMIN.

Entries starting with DB6 are DB2 for LUW related. The following entries control MDC settings: 1 DB6_MDC_FOR_PSA = YES/NO default NO 2 DB6_MDC_FOR_AGGREGATES = YES/NO default YES

WW DB2 SAP Technical Enablement and Support Team

Page 36

DB2 LUW for SAP BW Lab Exercises

Unit 6 Deep Compression for SAP BW Run transaction RSRV: On the Analysis and Repair of BI Objects screen, expand Tests in Transaction RSRV All Elemetary Tests Database Double-click Data row compression of InfoProviders. to select the test. Double click on the row in the right side of the screen. A pop-up will appear.

6.1 Check the Compression Details for InfoCube

Select the InfoProvider you want to test ZSD_C01 and click Transfer. 6.2 Select the InfoProvider you want to check

Expand the row in the right side of the screen, high light the line InfoProvider=ZSD_C01, execute the test by pressing button Execute.

6.3 Execute the test

WW DB2 SAP Technical Enablement and Support Team

Page 37

DB2 LUW for SAP BW Lab Exercises

The result shows the compression feature is NOT enabled for the F fact and E fact tables of InfoCube ZSA_C01, and the F fact table size is 32.78MB.

6.4 Check the result

Run transaction DBACockpit, go to Space /BIC/FZSD_C01 and hit Enter. 6.5 Estimate Compression Ratio

Single Table Analysis, enter table name

Select the tab Compression Status. It shows that this fact table is not enabled for compression.

WW DB2 SAP Technical Enablement and Support Team

Page 38

DB2 LUW for SAP BW Lab Exercises

Click Compression Check button, on the following screen, click on Execute button. Note: since this is a small table, it is OK to choose Run in Dialog. If it is a large table, it is better to run in a background job.

When it finishes, click on Refresh button, and the compression check result is shown: It is estimated that 66% of pages will be saved.

WW DB2 SAP Technical Enablement and Support Team

Page 39

DB2 LUW for SAP BW Lab Exercises

Click on Compression On/Off button, on the following screen, choose Enable Compression and Run REORG, click Execute button.

6.6 Enable Compression

On the Schedule a New Action screen, click on Execute Immediately button.

WW DB2 SAP Technical Enablement and Support Team

Page 40

DB2 LUW for SAP BW Lab Exercises


You can use transaction SM37 to check the Reorg job status. Once it is completed, refresh the Single Table Analysis screen. And you will see that it is compressed with 66% pages saved.

6.7 Check the compression result

Flip to the tab Table, you will see the new table size is now 12864K.

Write down the Total Table Size, Total Index Size and No. of Pages with Data to the Work Sheet on the final page of this hand book.
You should notice that the table size and the No. of Pages with Data have decreased significantly.

WW DB2 SAP Technical Enablement and Support Team

Page 41

DB2 LUW for SAP BW Lab Exercises


Run transaction RSRT, enter Query Name ZSD_C01/BENCHMARK_QUERY_2, click on Execute + Debug, check flags Do not use cache and Display statistics data (under Others section), hit Continue button. After the query results are displayed press Back button in the toolbar of the result window, the runtime statistics of the query is displayed. 6.8 Run BI query again and verify the performance improvement after the fact table is converted to MDC. Comparing the result to 4.2

Question: how much time is spent in the database (Data Manager) this time?

Write down the Duration of Data Manager to the Work Sheet on the final page of this hand book.
In another SAP GUI window, go to DBACockpit -> Performance -> SQL Cache. On the Selection Criteria window, remove 100 from the Execution field, and enter the SELECT*FZSD_C01* in the SQL Text field. The following statement execution result is returned:

6.9 Check query performance and access plan

Double click on the statement, or click on the Explain button, you can get the access plan. Compare this access plan with the access plan you saw in exercise 5.11. They should be the same, except that the total estimated costs are different because of disk I/O cost saving on the compressed fact table.

Write down the Avg. Execution time, Buffer Quality, Rows Read, SQL Sorts and the total Estimated Costs to the Work Sheet on the final page of this hand book.
*Note* For more accurate comparison, especially to demonstrate the disk I/O cost saving by using MDC feature or compression feature, you need to run the query in a cold buffer pool, which means the table data should not have been cached in the buffer pool. This will require comparing the result on the first query run on a newly

WW DB2 SAP Technical Enablement and Support Team

Page 42

DB2 LUW for SAP BW Lab Exercises


started system. Therefore you might want to stop and restart your SAP system before running the query. As you can tell, the query time should be faster after the fact table has been compressed because of the savings on the disk I/O. Run program SAP_RSADMIN_MAINTAIN in transaction SA38. Enter DB6_ROW_COMPRESSION in the OBJECT field, and YES in the VALUE field, choose INSERT, then click on Execute button.

6.10 Change settings in table RSADMIN.

Run transaction SE16 - Data Browser Browse table: RSADMIN Restrict values in field OBJECT to DB6*. You will see now DB6_ROW_COMPRESSION is set to YES.

6.11 Check settings in table RSADMIN.

WW DB2 SAP Technical Enablement and Support Team

Page 43

DB2 LUW for SAP BW Lab Exercises

Unit 7 BI Operations Before starting the BI compression, lets check the total number of records in F fact table and E fact table of InfoCube ZSD_C01. How to do that? Hint use DBACockpit Single Table Analysis function. Results: F fact should contain 160600 records, and E fact table contains 0 records. Now move to DW Workbench screen. Lets check how many records was loaded in the request 14. Run transaction RSA1 Modeling InfoProvider Select benchmark Select Benchmarkcube and right-click Select Manage Select Requests tab.

7.1 Compress an InfoCube

Click on the Monitor icon on the line of request 14. You should see the detailed information of request 14. Click on Details tab, and expand Extraction and Transfer menu: You can see that there are 13640 records being extracted from the source file. Data was loaded in the package size of 1000. There were 14 data packages were created and loaded in BW.

WW DB2 SAP Technical Enablement and Support Team

Page 44

DB2 LUW for SAP BW Lab Exercises

Now go back to InfoProvider Administration screen, click on tab Collapse.

WW DB2 SAP Technical Enablement and Support Team

Page 45

DB2 LUW for SAP BW Lab Exercises


Enter the Job Name BI_COMPZSD_C01_REQ14, and Rquest ID 14. Before releasing the compression job, lets turn on ST05 SQL trace. Now click on Release button and it will schedule a background job. Click on the button Log to monitor the job status.

When the job is finished, go back to Requests tab, and click on Refresh button, you should see a check mark in the third column (Compression Status in InfoCube) on the line of Request 14.

WW DB2 SAP Technical Enablement and Support Team

Page 46

DB2 LUW for SAP BW Lab Exercises

Go to the DBACockpit Single Table Analysis, Enter table name /BIC/FZSD_C01, do a RUNSTATS in dialog. When the runstats finishes, you should see the table cardinality is changed from 160.600 to 146.960, which means 13640 records has been deleted in F fact table. Now check table /BIC/EZSD_C01. You should see its cardinality is 13640, which means 13640 records has been inserted into E fact table. Go to the ST05 screen and deactivate the trace. Display the trace. You should be able to find the following statements in the Trace List screen:

The above INSERT and DELETE statements are key statements to this InfoCube compression process. Move the cursor to the INSERT statement, and click on Explain button. You will see the full statement text and the access plan:

WW DB2 SAP Technical Enablement and Support Team

Page 47

DB2 LUW for SAP BW Lab Exercises

Try to understand this SQL statement. This is a INSERTSELECT statement. It basically select records from F fact table based on the request ID and insert these records into E fact table. Question: what index is used to select records from F fact table? Answer: a MDC block index on Package dimension. Shown below:

Go back to Trace List screen, move the cursor to the DELETE statement, and click on Explain button. You will see the full statement text and the access plan:

Do you understand what this DELETE statement does?

WW DB2 SAP Technical Enablement and Support Team

Page 48

DB2 LUW for SAP BW Lab Exercises


Now that we have some data being compressed into E fact table, we have InfoCube data stored in both F and E fact tables. How will this affect the query? Run transaction RSRT, enter Query Name ZSD_C01/BENCHMARK_QUERY_2, click on Execute + Debug, 7.2 Run the BI query check flags Display SQL/BIA Query (under Data Manager section), hit Continue button. Firstly you will see the first SELECT statement that selects from F fact table; click on the Back button, you will see the second SELECT statement that selects from E fact table; click on the Back button again, you will get the query result. Therefore the query result is a merged result from two separate queries, one from F fact table, and the other from E fact table.

Run program SAP_RSADMIN_MAINTAIN in transaction SA38. Enter DB6_MDC_FOR_AGGREGATES in the OBJECT field, and YES in the VALUE field, choose INSERT, then click on Execute button.

7.3 Enable MDC for aggregates

After this, you can run SE16 to display this parameter in table RSADMIN. 7.4 Create an aggregate

On the InfoProvider Administration screen of ZSD_C01, click on Rollup tab.

WW DB2 SAP Technical Enablement and Support Team

Page 49

DB2 LUW for SAP BW Lab Exercises

Click on Aggregates button to maintain aggregates of this InfoCube. On the following screen, click on Create by Yourself button.

On the Maintenance for Aggregate screen, Click on the Create New Aggregate button. Enter the aggregate description as below:

and hit Enter. Drag Sales Area dimension and Time dimension from the left window onto the newly cre-

WW DB2 SAP Technical Enablement and Support Team

Page 50

DB2 LUW for SAP BW Lab Exercises


ated aggregate ZSD_C01_SALES_TIME on the right window, as below:

Click on the Save button at the top of the window to save the aggregate definition. Then click on the Activate and Fill button. Click on Start button, and choose Immediately on the pop-up message box:

Click on the Jobs button and you will be directed to the Job Overview screen. On the Job

WW DB2 SAP Technical Enablement and Support Team

Page 51

DB2 LUW for SAP BW Lab Exercises


Overview screen, when the job BI_SAGR* job is completed, click on the Job Log button, you will see the following job logs. From this job log, you can tell how the aggregate is filled:

WW DB2 SAP Technical Enablement and Support Team

Page 52

DB2 LUW for SAP BW Lab Exercises

WW DB2 SAP Technical Enablement and Support Team

Page 53

DB2 LUW for SAP BW Lab Exercises


Use DBACockpit -> Space -> Single Table Analysis to check the table and index structure and statistics of aggregate F table /BIC/F100004 and /BIC/F100004. You should see that the aggregate fact table inherit the MDC definition of the InfoCube fact table. Therefore the aggregate fact table also has package and calmonth defined as MDC dimension.

7.5 Check aggregate fact tables

Since now we have the aggregate defined on both SALES AREA and TIME dimension, the original query we have run should select data from the aggregate rather than from the infocube. We can verify this by running the query again. Run transaction RSRT, enter Query Name ZSD_C01/BENCHMARK_QUERY_2, click on Execute + Debug, 7.6 Run BI query again check flags Display SQL/BIA Query (under Data Manager section), hit Continue button. Now you will see the SELECT statement that selects from the aggregate E fact table /BIC/E100004. click on the Back button then this query will be executed and the query result will be displayed.

WW DB2 SAP Technical Enablement and Support Team

Page 54

DB2 LUW for SAP BW Lab Exercises

WW DB2 SAP Technical Enablement and Support Team

Page 55

DB2 LUW for SAP BW Lab Exercises

Work Sheet Default table (no MDC) Total Table size Fact table Size Comparison Total Index size No. of Pages with Data MDC table Compressed MDC table

Default table (no MDC) RSRT Data Manager Duration Avg. Execution Time (ms) Rows Read Buffer Quality SQL Sorts Access Plan Estimated Costs (timerons)

MDC table

Compressed MDC table

Query Performance Comparison

WW DB2 SAP Technical Enablement and Support Team

Page 56

Vous aimerez peut-être aussi