EDUCAÇÃO E TECNOLOGIA

Troubleshooting SAP DWC Performance Issues with the HANA Plan Visualizer

This blog was also submitted at Applexus Blogs as part of our employee engagement towards ‘Knowledge Center’ initiatives.

Huge thanks to Ankur Goyal for his valuable inputs.

Problem Scenario & Landscape:

Our landscape involves creating reports (Stories) on SAP Analytics Cloud that uses a Live connection based to SAP Data Warehouse Cloud, where our reporting data models are located.

Figure%201%3A%20Reporting%20Landscape

Figure 1: Reporting Landscape

As with any Analytic scenario involving complex modelling and/or large volumes of data, sometimes there is a need to monitor the performance of the Dashboard. Dashboard performance will depend on the following factors:

  1. Back end Data Model performance (DWC data model in this case)
  2. Network performance
  3. Front performance: time used to render the widgets and the number of widgets

Note: It is recommended to limit the number of widgets on each Story page to ‘6’ as this is the cap of parallel requests most browsers (ex: Chrome) are capable of. Meaning, additional widgets will be ‘Stalled’ while the initial 6 widgets load and will only load after that.

You can read more about this behavior in the following link (Multiple TCP Connections).

Unfortunately, neither SAC nor DWC comes with an out-of-the-box performance analysis tool that can accurately gauge where bottlenecks occur that cause slow response-times on the reporting end.

The scope of this blog is to analyse the Data Source response time of the DWC Data Models..

Listed below is a high-level overview of the steps we undertake:

  1. Capturing the JSON Request from SAC to DWC by running the Trace
  2. Generating the PlanViz Output file
  3. Analyzing the HANA Visualized Plan

SAP DWC uses SAP HANA Cloud DB for data storage and execution, tools used for HANA performance analysis also can be used for analysing DWC performance.

The section below outlines the step-by-step process on how we can get to the HANA PlanViz analysis.

Pre-requisites for further analysis:

(1) Google Chrome Browser with access to Developer Tools to capture the JSON Request

Figure%202%3A%20Accessing%20Developer%20Tools

Figure 2: Accessing Developer Tools

(2) Any text and source code editor to properly format the JSON request (ex: Notepad++)

    • Also install the JSON Viewer Plugin on Notepad++

Figure%203%3A%20Source%20code%20editor%20with%20JSON%20Plugin

Figure 3: Source code editor with JSON Plugin

(3) A user with access to create a Database Analysis User on the DWC tenant side, requiring the  DW Administrator role This enables the reading of all space data, SAP HANA monitoring views, traces, reproduce issues and use explain plan. (Please check the following SAP Documentation for more information on this).

Figure%204%3A%20Create%20Database%20Analysis%20User

Figure 4: Create Database Analysis User

(4) Visual Studio Code to analyse the PlanViz output

Figure%205%3A%20SQL%20analyzer%20tool%20for%20SAP%20HANA

Figure 5: SQL analyzer tool for SAP HANA

Generating the HANA Visualized Plan:

Listed below we will go over, step-by-step, the process involved in generating the HANA Visualized Plan to thoroughly examine areas where the performance impact lies.

Capturing the JSON Request from within SAC by running the trace

(1) Open up the Developer Tools panel from within the Google Chrome browser as shown in Figure 2. Select the ‘Network’ tab from within it.

(2) Navigate to the SAP Analytics Cloud story that you want to analyse and select it.

Figure%206%3A%20Selecting%20a%20Story%20for%20Analysis

Figure 6: Selecting a Story for Analysis

(3) As each widget in your story loads, it will correspond to a single ‘GetResponse’ line recorded within the Network trace. Type in ‘GetResponse’ in the filter pane to filter only the necessary items you want to inspect.

(4) Now, we have a clear representation of the number of widgets loaded, and also the Time it took for each one to load. While most of our widgets have loaded within ~2.5s one widget is taking longer. Let us click on the ‘GetResponse’ record to perform further analysis.

Figure%207%3A%20Response%20times%20for%20Story%20widgets

Figure 7: Response times for Story widgets

(5) Next, under the Headers section go to the Request Payload area and click on ‘View Source’

Figure%208%3A%20Request%20Payload

Figure 8: Request Payload

(6) Here we find our initial JSON trace. Make sure to select ‘Show More’ to fully display all the text.

Figure%209%3A%20Request%20Payload

Figure 9: Request Payload

(7) Select the entire text within Request Payload and copy it. Note that to have properly selected it, ensure that a white fade envelops the entire text field.

Figure%2010%3A%20Capturing%20the%20JSON%20request

Figure 10: Capturing the JSON request

(8) Paste the text within Notepad++ & from under Plugins, select the JSON Viewer plugin (as shown in Figure 3) and click on Format JSON.

Figure%2011%3A%20Formatting%20the%20request

Figure 11: Formatting the request

(9) Set this formatted text aside for the moment as we now focus on creating the Database Analysis User.

Figure%2012%3A%20Formatted%20JSON%20request

Figure 12: Formatted JSON request

Creating the Database Analysis User within Data Warehouse Cloud

(1) Please refer to Figure 4 on how to access the Database Analysis User. Select ‘Create’. The ‘Create Database Analysis User’ prompt lets you set the User Name Suffix. Make sure to capture the Database Analysis User Name as this is required later.

Figure%2013%3A%20Creating%20Database%20Analysis%20User

Figure 13: Creating Database Analysis User

(2) IMPORTANT – Make sure to save all the following details in a Notepad. These details are necessary to be able to generate the PlanViz file and cannot be accessed once this below window is closed.

Figure%2014%3A%20Database%20Analysis%20User%20Details

Figure 14: Database Analysis User Details

(3) Once the DBA User is created, select it from within the User list and click on ‘Open Database Explorer’, as shown in the Figure below.

Figure%2015%3A%20Open%20Database%20Explorer

Figure 15: Open Database Explorer

(4) This opens up the SAP BTP login screen so as to be able to access the underlying HANA Database, please enter your DWC credentials here.

Figure%2016%3A%20Connecting%20with%20DWC%20user%20ID

Figure 16: Connecting with DWC user ID

(5) Optional – There might be an additional security check before you can access the SAP HANA Database Explorer. If so, please sign in with your S-User ID credentials.

Figure%2017%3A%20S-User%20ID%20authentication

Figure 17: S-User ID authentication

(6) Finally, we can access the SAP HANA Database Explorer panel. Here we can sign in to the SAP HANA Database using the Database User ID and Password we captured during initial creation of the Database User, as shown in Figure 14.

Figure%2018%3A%20Signing%20in%20to%20the%20HANA%20Database

Figure 18: Signing in to the HANA Database

Note: It is not recommended to enable the ‘Save Password’ option here

(7) Once successfully signed in, we can see the Database User we have created along with the Catalog & Database Diagnostic Files which we will use for further analysis

Figure%2019%3A%20HANA%20Database%20Explorer

Figure 19: HANA Database Explorer

Generating the PlanViz output file

(1) Upon logging in, right click on the Database and from the context menu select ‘Open SQL Console’

Figure%2020%3A%20Open%20SQL

Figure 20: Open SQL console

(2) In the console, first paste the following code. Ensure proper formatting so as to leave some blank rows between the first and second rows of text.

CALL SYS.EXECUTE_MDS (‘Analytics’, ”, ”, ”, ”, REQUEST=>’

 [Your code here]

‘, RESPONSE=>?);

 

(3) As shown in the figure below, paste the formatted JSON from the Notepad++ application into the SQL console, ensuring that the text is pasted in between the present rows of text.

Figure%2021%3A%20Pasting%20the%20JSON

Figure 21: Pasting the JSON request

(4) Once the entire text is pasted, let us execute the script.

Figure%2022%3A%20Executing%20the%20script

Figure 22: Executing the script

(5) If the JSON request has been captured and executed properly so far, the Result panel will appear as shown below without tossing any errors.

Figure%2023%3A%20Result%20panel%20after%20execution

Figure 23: Result panel after execution

(6) We can proceed onto the next step of generating the PlanViz file by selecting Analyze > Generate SQL Analyzer Plan File

Figure%2024%3A%20Generate%20SQL%20Analyzer%20Plan

Figure 24: Generate SQL Analyzer Plan file

(7) Give a name to the generated PlanViz file and Save. Initially this saves this file within the HANA Database Explorer in the location mentioned below.

Figure%2025%3A%20Saving%20the%20PlanViz%20file

Figure 25: Saving the PlanViz file

(8) This file can then be downloaded directly onto your local system. From within the ‘Plan Saved’ pop-up box, select the ‘Download’ option.

Figure%2026%3A%20Downloading%20PlanViz%20file%20locally

Figure 26: Downloading PlanViz file locally

Analyzing the HANA Visualized Plan:

Now that we have the PlanViz file saved to our local system, we can start analyzing this further to gain insights on the slow response time produced by our SAC widget. To do this, let us perform the following steps:

(1) Open Microsoft Visual Studio Code. From under File>Open File… select the PlanViz file we’ve saved to the local system in the previous section.

Figure%2027%3A%20Uploading%20the%20PlanViz%20file

Figure 27: Uploading the PlanViz file

(2) The file is now ready for analysis within Visual Studio Code.

Figure%2028%3A%20Analyzing%20PlanViz%20within%20Visual%20Studio%20Code

Figure 28: Analyzing PlanViz within Visual Studio Code

(3) Using this tool we can break down individual components of the processes (ex: Join executions, Calculation times) that occur within the underlying HANA database before a response is sent to the front-end Browser. We have included the below screenshots as a reference to show how the drill down works at a high-level.

Figure%2029%3A%20Analyzing%20specific%20nodes

Figure 29: Analyzing specific nodes

(4) Further analysis can be continued on a case-by-case basis. This will help you gain insights on in which specific part of the query execution process the bottleneck lies and thus how to resolve it.

To derive deeper insights from the PlanViz file we would like to direct you to one of the multiple resources online that delve deeper into this topic.