You are on page 1of 20

Query OLAP Cache Optimization in SAP BW

Applies to:
SAP NetWeaver 2004s BW 7.0

Summary
This article explains how to improve performance of long running queries using OLAP Cache. Author: Sheetal Maharshi
th

Company: Infosys Limited Created on: 13 Aug 2011

Author Bio
Sheetal Maharshi is working as an SAP BW consultant and has experience in many implementations of an Enterprise Date Warehouse, BW upgrade, BW Support, BWA and Reporting. .

SAP COMMUNITY NETWORK © 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 1

Query OLAP Cache Optimization in

SAP BW

Table of Contents
INTRODUCTION ................................................................................................................................................ 3 Pre- Requisite ..................................................................................................................................................... 3 Query Design Tips .............................................................................................................................................. 4 Filling OLAP Cache ............................................................................................................................................ 5 BEx Broadcasting Approaches ........................................................................................................................... 9 Query Monitor ................................................................................................................................................... 11 Read Mode: ...................................................................................................................................................... 12 Cache Mode: .................................................................................................................................................... 13 Optimization Mode: ........................................................................................................................................... 14 Cache Maintenance .......................................................................................................................................... 16 Related Content ................................................................................................................................................ 19 Disclaimer and Liability Notice .......................................................................................................................... 20

SAP COMMUNITY NETWORK © 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 2

 Reduce data Volume to be processed. The best way to avoid performance problems is to ensure that performance considerations are part of the ongoing development activities.sap.0 SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap.com | BOC .com | BPX .uac.Some of these techniques are:     By filling OLAP Cache By Creating Aggregates Using BWA Pre Calculated Web Templates This article explains how we can improve these long running queries using one of these techniques .sap. Even after careful designing and development. Most significant performance improvements are realized through careful design at the beginning of the development cycle.boc.com 3 .sap.Requisite  BW in SAP NetWeaver 7.sdn. Pre.com | UAC .Query OLAP Cache Optimization in SAP BW INTRODUCTION The goal of performance tuning is to minimize the response time of BW queries and to make the best use of the server's resources .OLAP cache.Basic rules for Performance Optimization are :  Eliminate all unnecessary processes. we can still face issues in query performances that can take longer time in execution.bpx. There can be many techniques to improve these long running queries .  Deploy parallelism at all available levels.

Below are some handy query design tips:  In most cases. it takes more time to read data for EXCLUSION as compared to INCLUSION.com 4 .bpx. try to avoid EXCLUSION option if possible. If Possible. it should be used cautiously per the business requirement. use of variables and dropdown boxes makes data access more specific. it can be integrated into Query free characteristics – enabling it to be used in navigation. When a query is run on the Multiprovider.      Do not use Total Rows if not needed. Keep the number of Characteristics in the query as small as possible to help reduce the number of cells sent to the front end.com | BPX .sap. This can be restricted by using Characteristic – 0INFOPROVIDER to only read the required Infoproviders. as characteristics in the INCLUSION can use database Indexes. define calculated and restricted Key Figures at the Infoprovider level instead of locally in the query.uac. it must not be added in the columns without a filter or a variable. Characteristics in the EXCLUSION cannot use Indexes. Graphics like – Charts.com | BOC . Characteristics should be placed in the rows and Key Figures in columns. Graphs etc. can impact query performance. Sometimes long running queries are the result of poor designing and not because of the amount of data it’s fetching.sap. For better performance. Check codes for variables processed by customer exits.sap. Avoid using cell definitions as far as possible as cell calculation by means of cell editor generates separate queries at query runtime. Check if aggregates are defined correctly and are suitable. as these are not aggregated like Infocubes. As characteristics may have potentially many values. Therefore.sap.boc.sdn. Alternately.Query OLAP Cache Optimization in SAP BW Query Design Tips Query Design can have a significant impact on the performance. In case a query is being designed on Data Store objects and Infosets. Hence.com | UAC .      SAP COMMUNITY NETWORK © 2010 SAP AG SDN . all the underlying Infoproviders are read.

Fig1 Fig 1 Or we can open from SAP Portal as well (Fig-2): Fig-2 SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sdn.com | UAC .com | BPX .bpx. the execution time is considerably reduced as the pre-calculated data is already stored in cache and there is no need to hit the database. queries.com 5 ..Query OLAP Cache Optimization in SAP BW Filling OLAP Cache Filling OLAP cache allows pre-calculation of the queries and the cache is filled with the data. Go to BEx Query Designer and open the query for which the OLAP Cache needs to be filled.sap.com | BOC . When the users runs WADs (Web Application Templates).boc.sap. The global OLAP cache buffers query result data. This option is available in BEx Broadcaster using option – Fill OLAP Cache.sap. As mentioned above. in order to provide them for further accesses. Below are the steps for creating BEx Broadcaster Settings for Filling OLAP Cache: 1.sap. reports or workbooks which have OLAP cache setting enabled. filling of OLAP Cache reduces query execution time considerably as it reduces the Database read time. thereby improving the performance.uac.

uac.boc.com | UAC .sap.com | BPX . Give the name of the new setting and select the Fill OLAP Cache from the dropdown of Distribution type (Fig-4): Fig-4 SAP COMMUNITY NETWORK © 2010 SAP AG SDN .com 6 .sap.bpx.com | BOC . Create new setting for the query (Fig-3).Query OLAP Cache Optimization in SAP BW 2.sdn. Fig-3 3.sap.sap.

uac. Give the variable values and click on the save button : (Fig-5 & Fig-6) Fig-5 Fig-6 SAP COMMUNITY NETWORK © 2010 SAP AG SDN .bpx.sdn.com | UAC .com 7 .com | BOC .sap.sap.sap.Query OLAP Cache Optimization in SAP BW 4.com | BPX .sap.boc.

com | BOC .Query OLAP Cache Optimization in SAP BW 5.sap.sap.com | UAC . Enter the description for the variable values and save the setting. OLAP cache setting can be directly execute or schedule. After saving .(Fig-7) Fig-7 6.sdn.com | BPX .uac.(Fig-8) Fig-8 SAP COMMUNITY NETWORK © 2010 SAP AG SDN .bpx.com 8 .sap.boc.sap.

sap. monthly or weekly basis.com | BPX .sdn.com 9 . The option “Direct Scheduling” can be used to schedule this job daily.bpx. Schedule broadcast on date/data change Scheduling can be done either with an event trigger or on daily. Fig-10 SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap.boc. weekly or monthly basis. Firstly in the BEx Broadcaster schedule the broadcaster to run on a data change event. (Fig-9) Fig-9 Add a data change event to the end of each datamart load process chain.com | BOC .Query OLAP Cache Optimization in SAP BW BEx Broadcasting Approaches 1. In the data change event you specify which InfoProvider has had it’s data changed (so that the OLAP cache has been erased for it) and broadcasts scheduled on the event for the InfoProvider are triggered.uac.sap. This event triggers the broadcasts which pre-fill the OLAP cache.sap.com | UAC .

uac. weekly or monthly basis SAP COMMUNITY NETWORK © 2010 SAP AG SDN . Instead if we want to fill the OLAP cache for Web Templates.sdn. another setting such as Broadcast to the Portal will need to be used.sap.Query OLAP Cache Optimization in SAP BW 2.com 10 . a single global setting can be created for the template. Fig-11 shows the settings for this: Fig-11 These settings can be saved and scheduling can be done either with an event trigger or on daily.com | BOC .com | UAC .boc. all of the underlying queries in the template as they would appear in the dashboard.bpx. Web Templates Web templates can contain multiple data providers and hence multiple queries. and hence cache. When scheduled and broadcasted. Instead of creating individual broadcast settings for each query in the template.sap.sap.sap.com | BPX . this web template setting will run. SAP doesn’t provide standard broadcast distribution type of filling OLAP cache for web templates.

and filter is read from the database.com 11 . This can be checked in tcode . Unlike with broadcasting a web template.com | BPX . i. more settings are available.com | BOC .> Properties The query definition tells the OLAP processor which data it must select.sap.e. by a characteristic. the free characteristics. Queries Queries can be individually broadcasted.bpx.uac. the InfoObjects in columns (key figures + characteristics).sap. such as broadcasting by multiple selection screen variants and by filter navigation on the query result set. doesn't need to be read until the dicing of the free characteristics in the query occurs. As early as the first navigation step of the query. with a distinction between the InfoObjects in rows (key figures + characteristics).sap. Fig-12 SAP COMMUNITY NETWORK © 2010 SAP AG SDN . the InfoObject data in the rows.com | UAC . and Optimization Mode of the query are given.sap. The query definition is determined by the InfoObjects of the query. columns. Query Monitor In the Properties tab of the Query Monitor different configuration settings for the Read Mode. Cache Mode. The data of the free characteristics. however.sdn. and the filter characteristics.boc.RSRT .Query OLAP Cache Optimization in SAP BW 3.

so that changes to navigation require read access to database. the OLAP processor requires only the necessary data for each navigation step. as all the data is present in the OLAP Cache.sap. Unlike the Reread the Data when Expanding a Hierarchy read mode. Where the Reread the Data read mode reads the expanded hierarchy completely in the first step.com | BPX . including the navigation through the free characteristics. For all additional navigation steps. Read Mode Read all Data Advantages Fast query navigation after first call. Another read access to the database is not required.com | UAC . Disadvantages First call is slow Requires more memory in OLAP Cache Recommedations Use this read mode only with small Infocubes.com 12 . If a deeper level of the hierarchy is required in another navigation step. ReRead data when expanding hierarchy First call is very fast because only required data is selected It selects smallest amount of data in the first call. Queries having few free chararteristics. The Reread the Data When Expanding a Hierarchy read mode selects the smallest amount of data.bpx. SAP COMMUNITY NETWORK © 2010 SAP AG SDN . ReRead the data First call is very fast because only required data is selected User have to wait for additional calls if the selection differs from the first call Use this read mode with large quantities of results.boc.com | BOC . In the Reread the Data read mode. the database must be accessed again. The data of the free characteristics is read only when it is needed for a dice. the data is aggregated and calculated from the main memory. All the data needed by the query is read from the database in the first step and loaded into the main memory of the OLAP processor. The read mode distinguishes between three types of read processes: (Fig -12)  Read all data (setting A: Query to Read All Data At Once)  Re read the data (setting X: Query to Read Data during Navigation)  Re read the data when expanding a hierarchy (setting H: Query to Read When You Navigate or Expand Hierarchies) The Read all Data read mode includes only one read procedure.sap.sap. Use this read mode for large hierarchies. Note: The default setting for a new query is Read Mode H: Query to Read When You Navigate or Expand Hierarchies.sap. This is why this mode requires the most reads on the database. the Reread the Data When Expanding a Hierarchy read mode reads only the data up to the selected hierarchy level in the first step.uac.Query OLAP Cache Optimization in SAP BW Read Mode: The read mode of a query determines how often the OLAP processor retrieves data from the database during query navigation. Data is read from the OLAP cache when the navigation results have already been selected once. this read mode always reads external hierarchies completely at the leaf level.sdn. even if a query selects a higher level.

boc. In case that memory is exhausted. Fig-13 Following are the different modes: Cache is Inactive (0) The cross transactional caching is deactivated which means that no result data will be held in Cache.sap. In this case only one cluster /BLOB table exists.Query OLAP Cache Optimization in SAP BW Cache Mode: The Cache mode determines whether and in what way the query results are to be saved in the OLAP cache.com 13 . It’s generally recommended to choose a directory that is proximate to the application server. excess data will be deleted from the memory. If the main memory is used up the excess data will be written background store (file.sap. accessible from all application servers. Note: The default setting for a new query is .com | BPX . Main Memory Cache with Swapping (2) The cached data is stored in the main Memory as well.bpx.sap.uac.com | UAC .sap. (Fig-13).Main Memory without Swapping (1) SAP COMMUNITY NETWORK © 2010 SAP AG SDN . BLOB table) and could be loaded back into the OLAP cache memory when executing another request Persistent Cache per Application server (3) The Cache data is stored persistently as cluster table or BLOB in a database or as a file.com | BOC . but can be accessed and written by all application servers.sdn. Main Memory without Swapping (1) The cached data is stored in the main memory. Persistent Cache Across each Application server (4) The Cache data is stored persistently as cross application server cluster table or BLOB in a database or as a file in a network.

bpx.sap. SAP COMMUNITY NETWORK © 2010 SAP AG SDN . since the last operation. Option 1 Query Optimization with Individual Periods in Days.sdn. Option 9 Query Optimization Inactive.uac. but we can also select the period of optimization in days.sap.com | UAC .com | BOC . This is done after first execution and again after certain period.Query OLAP Cache Optimization in SAP BW Optimization Mode: You can set the optimization mode of the query in the dialog (Fig-14): Option 0 Query Will Be Optimized after generation i. In this mode.sap. This mode is identical to option 0. Fig-14 Note: The default setting for a new query is – 0 Query Will Be Optimized after Generation. the size of the memory structure in which data is stored will be determined by the OLAP processor.e.com | BPX .boc.sap. the memory structure of the table is not optimized after generation of the query.com 14 .

we can use the Query Mass Maintenance feature from Query Monitor.Query OLAP Cache Optimization in SAP BW We can also change the query properties for all or selected queries of an InfoProvider.boc.sdn. use the menu path RSRT → Environment → Query Mass Maintenance When all the required setting changes are done .sap.com 15 .sap.com | BOC . We will get following message on the Status bar of RSRT t-code: “Queries Adjusted Successfully” SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap.bpx. click on Generate report to regenerate the queries for the new settings to take effect .com | BPX .com | UAC .uac.sap. For this.

com | BPX . These two caches can is set up with different parameters.bpx.RSRCACHE.boc. as the global cache is accessed across multiple users. Local cache data is retained in the roll area as long as it is required by the OLAP processor for that user.sap. The size parameters should be reviewed periodically depending on cache usage. e. The t-code used for this purpose is .sap. (Fig-14) Technically. the underlying data has changed and the cache is invalidated.com 16 .Query OLAP Cache Optimization in SAP BW Cache Maintenance We need to maintain the OLAP cache.sap. The local and global cache size values should be generally extended from their default settings when SAP BW is installed. hit ratio and overflow.com | BOC . or depending on the persistence mode will be swapped to disk when the cache size is exceeded.uac. the OLAP cache consists of two caches: Local cache and Global cache. Fig-14 SAP COMMUNITY NETWORK © 2010 SAP AG SDN . The cache size must be appropriate to manage the frequency of query calls and the number of users. Local Cache: The local cache is accessed by a single user within a session on an application server. Global Cache: Global cache data is shared by all users across all application servers.com | UAC . Some indications that your cache size should be extended are:    The number of cache entries has filled the capacity of the cache at least once.sdn.sap. The global cache size should be larger than the local cache size. Ratio of hits to gets is lower than 90%. Average number of cache entries corresponds to at least 90% of the capacity or has reached this capacity around 30% of the time.g. Global cache data is retained for as long as it is required and will either be deleted when it is no longer needed. such as size.

sdn.bpx.Query OLAP Cache Optimization in SAP BW Note: The values shown in the above fig may differ. the Read flag is checked for entries that were read from the Cache.sap.Program RSR_CACHE_RSRV_CHECK_ENTRIES can be scheduled to run on a regular basis to remove the unused cache entries. T-code used for configuring the cache parameters is RSCUSTV14 or by using T-code-SPRO. Following fig shows various Cache modes present in the t-code.sap.com | UAC .sap. Regular audit of the Cache should be done by the support team for individual system. BASIS team determines the best values for these settings and therefore should not be modified.uac.sap.boc.com 17 .com | BOC .com | BPX .RSRCACHE: Fig-15 For Cache Mode 1 and 2. (Fig-16) Fig-16 SAP COMMUNITY NETWORK © 2010 SAP AG SDN .

Enter table name – RSRREPDIR and click on Display. 3.com | BPX .bpx.sap. The CACHEMODE and READMODE fields below show the settings of the individual queries.uac. 2.sdn. Go to SE16.sap. Follow these steps: 1. (Fig-17) Fig-17 To view the cache settings for all or selected queries.Query OLAP Cache Optimization in SAP BW For Cache modes 3 and 4.com 18 .com | UAC .boc. the RSRREPDIR table can be viewed.sap.com | BOC . this can be checked from the context menu and by clicking Detail. (Fig-18) Fig-18 SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap.

sap.htm http://help.com | BOC .com 19 .sdn.com/2011/02/cache SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap.sap.htm http://help.boc.com/saphelp_bw32/helpdata/en/00/241da12ef84f40bb6ecd3ae73d8b58/content.uac.sap.htm http://help.htm http://www.sap.Query OLAP Cache Optimization in SAP BW Related Content http://help.sap.sap.com/saphelp_bw32/helpdata/en/d9/31363dc992752de10000000a114084/content.com/saphelp_nw70/helpdata/en/41/b987eb1443534ba78a793f4beed9d5/content.skeneintelligence.bpx.sap.com | UAC .com/saphelp_nw70/helpdata/en/2a/b37f425b595551e10000000a1550b0/content.com | BPX .

com 20 .sap. SAP will not be held liable for any damages caused by using or misusing the information. or seek to hold. code or methods suggested in this document. SAP responsible or liable with respect to the content of this document. including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP.boc.sap.sap.Query OLAP Cache Optimization in SAP BW Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .uac.com | BPX .com | BOC .bpx. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample.sdn. and anyone using these methods does so at his/her own risk. You agree that you will not hold. Changes made based on this information are not supported and can be overwritten during an upgrade.sap.com | UAC .