Exercise Objectives
After completing this exercise, you will be able to:
- Control parallelization in the data flow of a calculation view.
- Check parallelization in the SAP HANA SQL Analyzer.
Business Example
Your calculation view processes large volumes of data and there appears to be a bottleneck caused by the generation of a complex calculated column within the data flow. You would like to force the data to be processed in parallel where the bottleneck occurs in the data flow to try and improve the performance of the calculation view.
Overview of Exercise Tasks
- Task 1: Create a Calculation View and implement parallelization
- Task 2: Analyze the execution to check parallelization
Prerequisites
Prerequisites
Your SAP Business Application Studio development environment should have been set up and the HC300 project imported and deployed.
Task 1: Create a Calculation View and Implement Parallelization
Steps
If needed, launch SAP Business Application Studio and start your HCMOD development space.
In your exercises folder, create a new calculation view with the following properties:
Field Value Name CVD_CONTROL_PARALLELIZATION Label CVD_CONTROL_PARALLELIZATION Data Category DIMENSION In the Explorer view, right-click the folder HC300_A####→db→src→exercises folder and choose New File.
Enter CVD_CONTROL_PARALLELIZATION.hdbcalculationview as file name and press Enter.
Enter the calculation view label and Data Category as specified in the table.
Choose Create.
Add a new Projection node and rename the node label as Start_Parallel.
Select and put a Projection node from the palette into the area at the very bottom of the data flow canvas.
Right-click the node and choose Rename and enter the name Start_Parallel and press Enter.
In the new Projection node, add the following data source:
Table HC::Empl_Salary_Current
Select the Start_Parallel node that you just added.
Choose +Add Data Source.
In the Find Data Sources window, click the search field and enter empl.
In the search results, select the table HC::Empl_Salary_Current.
Choose Finish.
Expand the Details panel.
Choose the
Expand Details Panel icon in the top right corner of the screen.
On the Mapping tab of the new Start_Parallel node, add all columns to the output.
Select the new Start_Parallel node and on the Mapping tab, right-click the data source HC::Empl_Salary_Current and choose Add to Output so that all three columns are added to the output pane.
Enable the Setting Partition Local Execution to start the parallelization and choose Year for the partition column.
Expand PROPERTIES section of the mapping tab (the lower part of the mapping tab)
If you don't see the setting Partition Local Execution, re-select the data source HC::Empl_Salary_Current so that the setting Partition Local Execution appears under PROPERTIES.
Select the setting Partition Local Execution so a tick appears in the box.
Using the Partition Column drop-down selector, choose the column Year.
Add a new Projection node above the one created earlier and rename the node label as Processing_In_Parallel.
Select and put a Projection node from the palette into the canvas area between the two existing projection nodes.
Right-click the new node and choose Rename and enter the name Processing_In_Parallel so it has a clear meaning.
Connect the projection node Start_Parallel to the projection node Processing_In_Parallel and map all columns to the output.
Drag a line from Start_Parallel projection node to the Processing_In_Parallel projection node to connect them.
On the Mapping tab of the Processing_In_Parallel projection node right-click the data source Start_Parallel and choose Add to Output so that all three columns are added to the output pane.
In the projection node Processing_In_Parallel, create a new calculated column using the information in the table below:
Setting Value Name MonthlySalary Data Type DECIMAL Length 10 Scale 2 Expression "TotalSalary" / 12 Hint
Make sure to use double quotes in the SQL expression so that the case of the TotalSalary column name is passed properly to the expression as TotalSalary, not TOTALSALARY.Select the projection node Processing_In_Parallel then select the tab Calculated Columns and choose the Add button.
Select the template calculated column CC_1 and enter the details from the table.
Add a new Union node above the projection node Processing_In_Parallel and rename the union node label as Stop_Parallel.
Select and drop a Union node from the palette to the area directly above the Processing_In_Parallel projection node.
Right-click the union node and choose Rename and enter the name Stop_Parallel so it has a clear meaning.
Connect the projection node Processing_In_Parallel to the union node Stop_Parallel and map all columns to the output.
Drag a line from Processing_In_Parallel projection node to the Stop_Parallel union node to connect them.
On the Mapping tab of the Stop_Parallel union node right-click the data source Processing_In_Parallel and choose Add to Output so that all four columns are added to the output pane.
Terminate the parallel processing in the union node.
In the union node, re-select the data source Processing_In_Parallel so that the setting Partition Local Execution appears under PROPERTIES (clicking the header of the data source acts like a toggle between settings under properties).
Select the setting Partition Local Execution so a tick appears in the box.
Connect the union node Stop_Parallel to the default projection node and map all columns to the output.
Drag a line from Stop_Parallel union node to the default projection node to connect them.
Select the default projection node and on the Mapping tab right-click the data source Stop_Parallel and choose Add to Output so that all columns are added to the output pane.
Use the auto layout feature to properly display the calculation view scenario.
Choose the Auto Layout icon to rearrange the scenario symbols.
Deploy the CVD_CONTROL_PARALLELIZATION calculation view.
Choose the Deploy icon for your CVD_CONTROL_PARALLELIZATION calculation view..
In the Console pane, check that the deployment completes successfully.
Task 2: Analyze the Execution to Check Parallelization
Steps
Open SAP HANA Database Explorer tool and generate the SELECT statement.
Open the SAP HANA Database Explorer view.
Select your HDI container, expand its content and select Columns Views.
In the Catalog Browser sub-pane, set the filter to control.
Right-click on the HC::CVD_CONTROL_PARALLELIZATION view and choose Generate SELECT statement.
Generate the SQL Analyzer Plan file. Use SQLA as prefix.
Top-right of the SQL console tab, choose ...→Executed Plan.
Enter SQLA as File Name Prefix.
Choose Save.
Result
The HANA SQL Analyzer view opens, showing the query execution plan.Check the parallel execution of the query.
Select the PLAN GRAPH tab.
Scroll down the execution plan to find the first operations.
You should see two parallel table scans. One with a filter on year 2022 and another one on the year 2023.
Close all the open tabs in Business Application Studio and go back to the Explorer view.
Right-click any open tab and choose Close All. Don't save anything.
Select the Explorer view.