Professional Documents
Culture Documents
for Performance
Abani Pattanayak, SAP HANA CoE
Nov 12, 2015
Disclaimer
This presentation outlines our general product direction and should not be relied on in making a
purchase decision. This presentation is not subject to your license agreement or any other
agreement with SAP. SAP has no obligation to pursue any course of business outlined in this
presentation or to develop or release any functionality mentioned in this presentation. This
presentation and SAP's strategy and possible future developments are subject to change and may
be changed by SAP at any time for any reason without notice. This document is provided without a
warranty of any kind, either express or implied, including but not limited to, the implied warranties of
merchantability, fitness for a particular purpose, or non-infringement. SAP assumes no responsibility
for errors or omissions in this document, except if such damages were caused by SAP intentionally
or grossly negligent.
Public
| HY B RI D
Processing Services
Application Services
Web Server
| CL O UD
JavaScript
Spatial
Graph
Predictive
Search
Text
Analytics
Streaming
Analytics
Series
Data
Business
Functions
Data Virtualization
ELT &
Replication
ALM
Fiori UX
Graphic
Modeler
Application Lifecycle
Management
Data
Quality
Database Services
Columnar
OLTP+OLAP
Multi-Core &
Parallelization
Advanced
Compression
Multitenancy
Multi-Tier
Storage
Data
Modeling
Openness
Admin &
Security
Overview
SQL Query
Memory Usage
CPU Usage
Concurrency
Public
Single/Multi-Tenant (Shared)
Public
Visualize plan
HDBAdmin
Public
Public
Public
View properties
Review the joins
Calculated columns
Scripted views
Cardinality of dataset
Public
10
Explain plan
https://www.youtube.com/watch?v=YfkGutsz5Uo
https://help.sap.com/saphelp_hanaone/helpdata/en/20/d9ec5575191014a251e58ecf90997a/content.htm
http://sapbw.optimieren.de/hana/hana/html/sql_explain_plan.html
Public
11
Visualize plan
http://scn.sap.com/community/hana-in-memory/blog/2012/12/20/show-me-the-timelines-baby
Public
12
HDB Admin
Public
13
Public
14
No of aggregations performed
Degree of parallelization
Public
16
17
Filters
Reduce the dataset as early as possible. Use design time filters at the lowest level.
Input Parameter: Placeholders part of the models.
Can be used in Calculation. Can accept multiple values (SP09)
Can be derived from table. Can be derived from store procedure (SP09)
Ensure Variables (where clause) is pushed to the lowest level. Confirm using Visualization Plan.
Use analytical privilege and SQL analytical privilege (SP10) to filter data.
Avoid script-based calculation view, WHERE clause will not be pushed down.
Using Filter is better than using Inner Join to limit the dataset.
Public
18
Joins are the most expensive operation. Consider pushing most of the joins (at least on the tables
with high cardinality) to the lowest level.
Columns participating in the Joins are also selected (even if not requested) during query execution.
Hence direct impact on the cardinality of the dataset.
Public
19
Type of calculation
Distinct count is a complex operation and very CPU intensive compared to a simple aggregation
like sum or count. CPU usage will exponentially high esp. with high cardinality counters like
Transaction Count. These counters must be computed in the Analytic View level (where possible).
Attributes used in restricted or calculated measure are also requested and may increase the
cardinality of the dataset.
Calculation with data type conversion are expensive. Avoid where possible.
Watch out for calculations (like String_Args) which execute in the row-engine.
Public
20
Join pruning
Specify Cardinality for all Joins (1:1, n:1 etc.). Avoid m:n (Cartesian product)
Referential Join to attribute view (with design time filter) will behave as Inner Join
Specify Optimize Join = True for Left Outer and Text Joins (SP09 onwards)
Temporal Join to attribute views (with design time filter) will always execute.
Public
21
Model pruning
Public
22
Use of DB engines
Public
23
Degree of parallelization
Consider using UNION in place of JOINS in calculation view, esp. while dealing with similar dataset
(plan & actual).
Implementing a logical partitioning model, may reduce query runtime but will increase CPU usage.
Avoid single datasource (or node) feeding multiple nodes in calculation view.
Public
24
To reduce the network data transfer (i.e. to push the joins to each node) in a scale-out deployment
Collocate the master and fact data tables in the same node
Replicate master data to all nodes (if the fact table is distributed across multiple node)
Tables in _SYS_BI schema cant be replicated to all nodes
Consider applying multi-level partitioning with hash-partitioning (on single field) in the first level. This
will ensure, calculations can be computed on each node and each partition.
Public
25
Caching
Public
26
Dimension
Dimension
Fact
Table
Dimension
Consider building models with a star-schema/cube. The fact table (measures) is surrounded by various
dimensions. The star-schema can be built using analytic views or star-join calculation views (comparable
performance in SP09).
Public
28
After
Public
29
Public
30
Transformation
Public
31
Joins
Use Unions (with constants) to combine large data sets
Join views (within Calculation Views, within Universes or
using SQL) with caution. Use WHERE clauses + data filters
that can be pushed down into each view
Define cardinality N:1 fact to dimension (star schema) &
enforce left-outer join where possible
Minimize long join chains and big data set joins. Where
possible move data foundation joins into Attribute views
Calculations
Imbed business logic calculations into modeled views instead of within SQL statements, Procedures, Universes or front end
Minimize the use of expensive calculations, row based expressions & data manipulation including Calculated attributes
Transform complex expressions before hand using SLT, Data Services or Generated Columns
2015 SAP SE or an SAP affiliate company. All rights reserved.
Public
32
Public
33
Customer Workshop
Beverage Major
Stats
before: 5mins, after: 3sec
Changes (SP08)
Public
35
Stats
before: 30sec, after: 3sec
before: 2min (concurrency 5), after: 7 sec (concurrency 15)
Public
36
Grocery Retailer
Stats
Before
After
Changes (SP08)
Public
37
Audit Firm
Stats
Firm Stats
before: 19min, after: 8sec (1 user)
My Stats
before: 17sec, after: 1sec
before: 2min (concurrency 10), after 40sec
(concurrency 400)
Changes (SP09)
Public
38
https://scn.sap.com/community/hana-in-memory/blog/2015/11/03/the-art-and-science-of-hanaperformance-modeling
Public
39
Thank you
Contact information:
Abani Pattanayak,
SAP HANA Distinguished Engineer
Principal Consultant, SAP HANA CoE
abani.pattanayak@sap.com / 1 647-406-3392
2015 SAP SE or an SAP affiliate company. All rights reserved.
Public
41