0202 - Modeling - Best Practice.pdf
Transcript of 0202 - Modeling - Best Practice.pdf
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 1/38
SAP HANA 1.0Modeling Best Practice Notes
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 2/38
© 2012 SAP AG. All rights reserved. 2This 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 .
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.
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 3/38
© 2012 SAP AG. All rights reserved. 3This 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 .
Agenda
General data movement in SAP HANA
Olap Engine Vs Calculation Engine Queries
Column Engine Vs Row Engine Queries
Analytical View WHERE clauses and filters
Calculation Views WHERE clauses and filters
Calculated Attributes Calculated Measures & Counters
Joining Views & Tables
Script based Calculation views Vs. Graphical Calculation views
Explorer Information Space
Aggregation Node
Multi Dimensional Reporting flag
Constraint filters
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 4/38
© 2012 SAP AG. All rights reserved. 4This 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 .
Column
Engine
Row
Engine
Olap
Engine
Join
Engine
Calculation Engine
Calculation Views
Client / Application
Row
Store
Column
Store
Attribute
Views
Analytical
Views
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 5/38
© 2012 SAP AG. All rights reserved. 5This 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 .
SPART KWMENG
ABC 60
SELECT
SPART
SUM(KWMENGA)
SUM(KWMENGB)
SUM(KWMENGC)
SUM(TOTAL)FROM CALC VIEW
GROUP BY SPART
SPART KWMENG
ABC 180
SPART KWMENG
EFG 60
SPART KWMENGA KWMENGB KWMENGC
ABC 60 0 0
ABC 0 180 0
EFG 0 0 60
SPART PLANT A PLANT B PLANT C TOTAL
ABC 60 180 0 240
EFG 0 0 60 60
SELECT SPART, SUM(KWMENG)
FROM AV GROUP BY SPART
AV C AV A AV B
1 – Analytical View static filters
• Dimensions and measures used in the queries will be pushed down and used in
subsequent queries where possible
• Static design time filters defined directly on views will get applied before the querystarts to execute
C A L C E N G I N E
O L A P E N G I N
E
Warning!
Refrain f rom
moving large
datasets
between engines
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 6/38
© 2012 SAP AG. All rights reserved. 6This 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 .
SPART MATNR KWMENG
ABC DPC1017 60
SELECT
SUM(KWMENG_A)
SUM(KWMENG_B)
SUM(KWMENG_C)
SUM(TOTAL)
FROM CV
WHERE MATNR = DPC1017
GROUP BY SPART
SPART MATNR KWMENG
ABC DPC1017 60
SPART MATNR KWMENG
- - -
SPART MATNR KWMENGA KWMENGB KWMENGC
ABC DPC1017 60 0 0
ABC DOC1017 0 60 0
PLANT A PLANT B PLANT C TOTAL
60 60 0 120
WHERE clause is
pushed down
SELECT SPART, MATNR, SUM(KWMENG)
FROM AV WHERE MATNR = ? …
AV C AV A AV B
2 – Analytical View static filters with WHERE clause
• WHERE clauses are generally pushed down to Analytical Views through Unions
although some restrictions apply.
• Even through SPART is not selected as a dimension in the query it is included in the Analytical View query due to the GROUP BY clause
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 7/38
© 2012 SAP AG. All rights reserved. 7This 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 .
SPART WERKS KWMENG
ABC 100 60
SPART WERKS KWMENG
ABC 1000 180
SPART WERKS KWMENG
EFG 1200 60
SPART KWMENGA KWMENGB KWMENGC
ABC 60 0 0
ABC 0 180 0
EFG 0 0 60
FILTERS pushed
down
SELECT SPART, WERKS, SUM(KWMENG)
FROM AV WHERE WERKS = ?
SELECT
SPART
SUM(KWMENGA)
SUM(KWMENGB)
SUM(KWMENGC)
SUM(TOTAL)FROM CV
GROUP BY SPART
AV A AV A AV A
SPART PLANT A PLANT B PLANT C TOTAL
ABC 60 180 0 240
EFG 0 0 60 60
3 – Calculation View static filters
• Static filters defined on Projection nodes will get pushed down automatically
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 8/38
© 2012 SAP AG. All rights reserved. 8This 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 .
SPART MATNR WERKS KWMENG
ABC DPC1017 100 60
FILTERS pusheddown
SELECT SPART, MATNR, WERKS,
SUM(KWMENG) FROM AV WHERE
WERKS = ? AND MATNR = ? …
SELECT SPART
SUM(KWMENGA)
SUM(KWMENGB)
SUM(KWMENGC)
SUM(TOTAL)
FROM CV
WHERE MATNR = DPC1017GROUP BY SPART
AV A AV A AV A
SPART PLANT A PLANT B PLANT C TOTAL
ABC 60 60 0 120
SPART MATNR KWMENGA KWMENGB KWMENGC
ABC DPC1017 60 0 0
ABC DOC1017 0 60 0
SPART MATNR WERKS KWMENG
ABC DPC1017 1000 60
SPART MATNR WERKS KWMENG
- - - -
4.1 – Calculation View filters with WHERE clause
• Static filters defined on Projection nodes will get pushed down automatically
• Dimensions and measures used in queries will get pushed down where possible
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 9/38
© 2012 SAP AG. All rights reserved. 9This 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 .
Warning!
Both WERKS and
MATNR FILTERS are
not pushed down
SELECT WERKS, MATNR,
SUM(KWMENG) FROM AV A
SELECT WERKS
SUM(KWMENGA)
SUM(KWMENGB)
SUM(TOTAL)
FROM CV
WHERE MATNR = DPC1018GROUP BY WERKS
AV A
WERKS PLANT A PLANT B TOTAL
1000 1400 0 1400
4.2 – Calculation View filters with WHERE clause
WERKS MATNR KWMENG
100 DPC1017 700
1000 DPC1017 700
1000 DPC1018 1400
1200 DPC1019 700
1500 DPC1023 200
WERKS MATNR KWMENG
100 DPC1017 700
1000 DPC1017 700
1000 DPC1018 1400
1200 DPC1019 700
1500 DPC1023 200
WERKS MATNR KWMENG
1000 DPC1018 1400
Hint!
To push down WHERE clause
add a second copy of the
Analy tical View
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 10/38
© 2012 SAP AG. All rights reserved. 10This 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 .
SELECT YEAR
SUM(A_GROSSREVENUE)
SUM(A_SALESDEDUCTION)
SUM(A_PRODUCTVARIANCE)
FROM AV AWHERE MATNR = DPC1017
GROUP BY YEAR
SELECT YEAR, MATNR, SUM(A_GROSSREVENUE),
SUM(A_SALESDEDUCTION),SUM(A_PRODUCTVARIANCE)
FROM AV/olap WHERE MATNR = DPC1017
GROUP BY YEAR, MATNR
5 – Calculated Attributes
Calculated Attributes
• A_CURRENT_YEAR_CA: midstr(string(now()),1,4)
• A_PREVIOUS_YEAR_CA: string(double(“A_CURRENT_YEAR_CA")-1)
• A_FILTER_CA: if(“A_CURRENT_YEAR_CA"="YEAR",1,if(“A_PREVIOUS_YEAR_CA"="YEAR",2,-1),-1)
YEAR CROSS REV SALES DEDUCT PROD VAR
2011 500 200 300
2012 300 100 200
Note!
WHERE clause can
be pushed down
Warning!
Refrain f rom
moving large
datasets
• The existence of Calc. Attributes results in the creation of a wrapper Calc. runtime object
• The Calc. View wrapper will always get executed regardless if any Calc. Attributes are selected
and then query the Analytical View via the (/olap) runtime object
Warning!
Use with caution
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 11/38
© 2012 SAP AG. All rights reserved. 11This 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 .
SELECT
YEAR,
A_FILTER_CA
SUM(A_GROSSREVENUE)
SUM(A_SALESDEDUCTION)
SUM(A_PRODUCTVARIANCE)
FROM AV AWHERE MATNR = DPC1017
GROUP BY YEAR,
A_FILTER_CA
SELECT YEAR, MATNR,
SUM(A_GROSSREVENUE),
SUM(A_SALESDEDUCTION),SUM(A_PRODUCTVARIANCE)
FROM AV A/olap WHERE MATNR = DPC1017GROUP BY YEAR, MATNR
6 – Calculated Attributes
YEAR FILTER CROSS REV SALES DEDUCT PROD VAR
2011 2 500 200 300
2012 1 300 100 200
Note!
WHERE clause can
be pushed down
• Dimensions and measures used in queries will get pushed down where possible
• Calc. Attributes (i.e. A_FILTER_CA) are executed in the Calc. View wrapper and thus
will not be pushed down into Analytical views
• The Calc. Attributes will execute only after the results from the /olap view query aretransferred to the Calc. View
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 12/38
© 2012 SAP AG. All rights reserved. 12This 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 .
SELECT
YEAR,
SUM(A_GROSSREVENUE)
SUM(A_SALESDEDUCTION)
SUM(A_PRODUCTVARIANCE)FROM AV A
WHERE MATNR = DPC1017
AND A_FILTER_CA = 1
GROUP BY YEAR,
A_FILTER_CA
SELECT YEAR, MATNR, SUM(A_GROSSREVENUE),SUM(A_SALESDEDUCTION),SUM(A_PRODUCTVARIANCE)
FROM AV A/olap GROUP BY YEAR, MATNR
7 – Calculated Attributes USED in WHERE clause
YEAR CROSS REV SALES DEDUCT PROD VAR
2012 300 100 200
Warning!
WHERE clause i s
not pushed downdue to the existence
of a Calc. Attribute
filter
• Since the Calc attribute A_FILTER_CA is used in the SQL WHERE clause the MATNR
clause is not pushed down
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 13/38
© 2012 SAP AG. All rights reserved. 13This 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 .
SELECT
QUARTER
SUM(NETWR_PREVIOUS)
SUM(KWMENG_PREVIOUS)
SUM(KWMENG_CURRENT)SUM(NETWR_CURRENT)
FROM CALC VIEW
GROUP BY QUARTER
SELECT QUARTER,YEAR, SUM(KWMENG),
SUM(NETWR) FROM
AV/olap GROUP BY
QUARTER, YEAR
AV A AV A
8 – Dynamic Calculated Attribute Filter + Modeled Calculation View
FILTER 2 FILTER 1
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 14/38
© 2012 SAP AG. All rights reserved. 14This 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 .
SELECT
QUARTER
SUM(NETWR_PREVIOUS)
SUM(KWMENG_PREVIOUS)
SUM(KWMENG_CURRENT)SUM(NETWR_CURRENT)
FROM CALC VIEW
WHERE MATNR = DPC1017
GROUP BY QUARTER
SELECT
QUARTER, MATNR, YEAR,SUM(KWMENG),
SUM(NETW) FROM AV/olap
GROUP BY QUARTER,
MATNR, YEAR
AV A AV A
Warning!
WHERE clause no t pushed down. Similar
as using Calc Attrib . WHERE clause
FILTER 2 FILTER 1
9 – Dynamic Calculated Attribute Filter + WHERE clause
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 15/38
© 2012 SAP AG. All rights reserved. 15This 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 .
SELECT
QUARTER
SUM(NETWR_PREVIOUS)
SUM(KWMENG_PREVIOUS)
SUM(KWMENG_CURRENT)SUM(NETWR_CURRENT)
FROM CALC VIEW
WHERE MATNR = DPC1017
GROUP BY QUARTER
SELECT QUARTER, MATNR,YEAR, SUM(KWMENG),
SUM(NETW) FROM VIEW
GROUP BY QUARTER,
MATNR, YEAR
OLAP A OLAP A
10 – Dynamic Calculated Columns Filter + WHERE clause
• Dynamic filter expressions defined on Projection nodes cannot pass down WHEREclauses causing potential large amounts of data to be transferred
FILTER 1FILTER 2
Warning!
WHERE clause not pushed down
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 16/38
© 2012 SAP AG. All rights reserved. 16This 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 .
SELECT
CA, SUM(NETWR)
SUM(CM2), SUM(RM)
FROM OLAP VIEW
GROUP BY CA
SELECT WERKS (ca), MATNR (cm), MATKL
(cm2), NETWR, RM (spart) FROM /olap
GROUP BY WERKS, MATNR, MATKL
11 – Calculated Measures + Dimensions
WERKS MATNR MATKL NETWR RM
100 DPC1017 012 600 600
1000 DPC1017 012 600 600
1000 DPC1018 012 1200 1200
1200 DPC1019 013 600 0
NETRW CM2 RM WERKS MATNR MATKL CM CA
600 1 600 100 DPC1017 012 1 100
600 1 600 1000 DPC1017 012 1 1000
1200 1 1200 1000 DPC1018 012 1 1000
600 1 0 1200 DPC1019 013 1 1200
CA NETRW CM2 RM
100 600 1 600
1000 1800 2 1800
1200 600 2 1800
CM2 references CM
• Dimensions referenced within expressions will be used in the /olap query
• Even though WERKS, MATNR, MATKL is not explicitly selected they are used
in expressions and implicitly included in the SQL statement• WHERE clauses will be pushed down into Calculation view wrappers
WHERE clause wi ll be
pushed down if used
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 17/38
© 2012 SAP AG. All rights reserved. 17This 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 .
SELECT
SUM(MATNR_COUNT)
SUM(WERKS_COUNT)
SUM(SPART_COUNT)
FROM ANALYTICAL VIEW
SELECT MATNR, WERKS, SPART FROM Analytical
View GROUP BY MATNR, WERKS, SPART
12 – Counters
WHERE clause wi ll be
pushed down if used
MATNR WERKS SPART
DPC1017 1000 ABC
DPC1018 1000 ABC
MATNR_COUNT WERKS_COUNT SPART_COUNT
3 3 2
OLAP AOLAP A
MATNR WERKS SPART
DPC1017 100 ABC
MATNR WERKS SPART
DPC1019 1200 EFG
MATNR WERKS SPART
DPC1017 100 ABC
DPC1017 1000 ABC
DPC1018 1000 ABC
DPC1019 1200 EFG
• Counters are available in graphical Calculation view / output node
• Preferred and optimized modeling technique for COUNT DISTINCT calculations
• Dimensions used in Counters will be pushed down into Analytical views
• Where possible use WHERE clauses in combination with Counters
OLAP A
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 18/38
© 2012 SAP AG. All rights reserved. 18This 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 .
SELECT
PRODUCT_NUMBER
SUM(NETRW_A)
SUM(NETRW_P)
FROM VIEW WHERE
SALES_ORG = 3000 AND
YEAR = 2012
13 – JoinsPRODUCT_NUMBER NETRW_A NETRW_P
011 100000 3000000
012 100000000 1000
014 10000 100000000
SELECT PRODUCT_NUMBER, YEAR,
SUM(NETRW) FROM AV GROUPPRODUCT_NUMBER WHERE YEAR = ?
Warning!
Where clause can be
pushed down into RAW
tables but not Attribute
Views. Could result i nmassive data movement an
jo in degradationSALES ORG
ATTRIBUTE VIEW
Note!Where Clauses will be pushed down i f
supplied. Prior revisions did not push downWHERE clauses underneath JOINS
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 19/38
© 2012 SAP AG. All rights reserved. 19This 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 .
SELECT
VKORG, SUM (NETWR)
FROM CALCULATION
VIEW GROUP BY
VKORG
14 – Joining Analytical Views
ROWNUM VKORG NETRW
1 0001 1000
… … …
55 0003 4939
JOIN
Even through VBELN and POSNR is not used in the query the
JOIN will force the materialization of both fields
Millions of rows
could pot entially be
involved in this JOIN
Warning!
Joining of Analytical Views
should not be done! This
approach may have severe
performance implications
Note!
Where Clauses will
be pushed down if
supplied
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 20/38
© 2012 SAP AG. All rights reserved. 20This 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 .
SELECT
C.CUSTOMER, P.PRODUCT, S.YEAR, S.SALES
FROM CUSTOMER_AT C
INNER JOIN SALES_AT S ON
C.NUMBER= S.CUSTOMER
INNER JOIN PRODUCT_AT P ONS.PRODUCT_ID = P.PRODUCT_ID
WHERE
C.CUSTOMER = Nelson
15 – Joining Attribute views using SQL
CUSTOMER PRODUCT YEAR SALES
Nelson HANA 2010 100000
Nelson ECC 2010 100000000
Nelson Business Objects Explorer 2010 200000000
Nelson Marketing Slides 2010 10000
SELECT PRODUCT,
PRODUCT_ID FROMPRODUCT_AT
SELECT CUSTOMER,
PRODUCT_ID, YEAR, SALESFROM SALES_AT
SELECT CUSTOMER, NUMBER
FROM CUSTOMER_ATWHERE CUSTOMER = ?
Warning!
Refrain from Joining Att ribute views. No WHERE clauses defined fo r these
At tr ibute Views therefo re potent ial ly large materiali zation and excess iverows. Do not join A ttribu te views without using WHERE clauses
JOIN will occur after the materialization o f all Att ribute views
WHERE clause i spushed down only to
this Attribute View
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 21/38
© 2012 SAP AG. All rights reserved. 21This 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 .
SELECT CUSTOMER,
PRODUCT, YEAR , SALES
FROM CALC VIEW
WHERE
CUSTOMER = Nelson
16 – Joining Attribute views within Calculation Views
SELECT PRODUCT,
PRODUCT_ID FROM
PRODUCT_AT
SELECT NUMBER,
PRODUCT_ID, YEAR, SALES
FROM SALES_AT
SELECT CUSTOMER,
NUMBER FROM
CUSTOMER_AT
Warning!
Refrain from joining Attribute
views. Where clause is not pushed
down when joining attribute views
CUSTOMER NUMB ER
001 Nelson
002 CPG Industries
003 Pharma and Co
004 Fremont Suppliers
005 Electronic Media
CUSTOMER PRODUCT YEAR SALES
Nelson HANA 2010 100000
Nelson ECC 2010 100000000
Nelson Business Objects Explorer 2010 200000000
Nelson Marketing Slides 2010 10000
Warning!
Excessive data due to noWhere clauses
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 22/38
© 2012 SAP AG. All rights reserved. 22This 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 .
SELECT CUSTOMER,
PRODUCT, YEAR , SALES
FROM CALC VIEW
WHERE
CUSTOMER = Nelson AND PRODUCT = HANA AND YEAR = 2010
17 – Join (Text) Tables within Calculation Views
SELECT PRODUCT,
PRODUCT_ID, SPRAS
FROM PRODUCT_AT
WHERE SPRAS = ?
SELECT CUSTOMER,
PRODUCT_ID, YEAR, SALES
FROM ACTUAL_SALES WHERE
YEAR = ?
SELECT CUSTOMER,
NUMBER, SPRAS FROM
CUSTOMER_AT WHERE
SPRAS = ?
Warning!
Where clause is not pushed
down in to tables that are
jo ined v ia Text Joins
CUSTOMER PRODUCT YEAR SALES
Nelson HANA 2010 100000
No intermediate result set
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 23/38
© 2012 SAP AG. All rights reserved. 23This 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 .
SELECT CUSTOMER,
PRODUCT, YEAR , SALES
FROM CALC VIEW
WHERE
CUSTOMER = Nelson AND PRODUCT = HANA
18 - Join (Inner, Left) Tables within Graphical Calculation View
SELECT PRODUCT,
PRODUCT_ID FROM
PRODUCT WHERE
PRODUCT = ?
SELECT CUSTOMER,NUMBER FROM
CUSTOMER T WHERE
CUSTOMER = ?
CUSTOMER PRODUCT YEAR SALES
Nelson HANA 2010 100000
Note!
Where clause pushed down and
jo ins occur without requi ring
intermediate result sets
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 24/38
© 2012 SAP AG. All rights reserved. 24This 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 .
19 – Ineffective data model with poor query performance
AN MATERIAL PLANT STOCK
WERKS MATNR
AT PLANT
WERKS BWKEY
JOIN
WERKS
AN MATERIAL STORAGE LOC STOCK
WERKS MATNR LGORT
AT STORAGE LOCATION
WERKS LGORT
JOIN
WERKS LGORT
AT MATERIAL
MATNR
AT MATERIAL VALUATION
VALUE MATNR BWKEY
AT MATERIAL VALUATED STOCK
WERKS MATNR LGORT
SELECT
WERKS,
VALUE
FROM
CA_STOCK_OVERVIEW
AT PLANT
WERKS BWKEY
JOIN
MATNR
JOIN
MATNR BWKEY
JOIN
MATNR WERKS LGORT
LGORT = 0
JOIN
WERKS
4 Million135 135 300 Million
200 267
3 Million
6 Million
260 Million
Warning!
Refrain from Joining views, WHERE
clauses can only be pushed down
into Analytical views and NOT
At tr ibute views.
Massive data sets has to be
materialized in order for the joins to
execute
Where clause (if supplied) will be pushed
down into Analytical views where possible
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 25/38
© 2012 SAP AG. All rights reserved. 25This 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 .
SELECT WERKS
SUM(QTY)FROM CALC VIEW
GROUP BY
WERKS
20 – Script based Calculation Views
Note!
Only WERKS is retrieved from the Database
Warning!
Refrain from u sing SQL in Calculation Views or
mixing SQL & CE functions! This approach may
have severe performance implications . Field
pruning is not possib le and as a result all fields
defined will be retrieved from the database(including underlying jo ins may get executed)
Both NAME1 & BWKEY will be
retrieved from the database even
though WERKS is the only field
requested
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 26/38
© 2012 SAP AG. All rights reserved. 26This 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 .
SELECT QUARTER,
SUM(PREVIOUS_NETWR)
SUM(CURRENT_NETWR)
SUM(ORDER_COUNT)
FROM ANALYTICAL VIEW
GROUP BY GROUPING SETS
LIMIT 26 STRUCTURED RESULT
WITH OVERVIEW PREFIX '#EXPL_TEMP'
((("QUARTER") ORDER BY
sum("PREVIOUS_NETWR")
DESC, "QUARTER" ASC))
21 – Explorer Information Space
Refrain from Grouping by KEYs without using
WHERE clauses. Using VBELN without any
WHERE clauses against the Analytical view
executes in 15 seconds and may process tensof millions of records
Q 2011 2012 COUNT
1 6101092 8621687 305
2 6317192 12762306 191
3 7304860 0 119
4 6771443 0 123
ROWNUM QUARTER YEAR VBELN NETWR
1 1 2011 81293934 122
… …. … … …
10 000 000 3 2015 34342334 233
Above query executes in 20 seconds when
Order Count is included and executes in ½second when the Order Count is excluded
SELECT QUARTER, YEAR, VBELN FROM Analytical
View GROUP BY QUARTER, YEAR, VBELN
Consider implementing a model that supports
push down of WHERE clauses into the
Analyti cal Views or using a front end too l that
supports WHERE clauses
Warning!
Referencing KEYs in
an Information Space
could severely impactperformance
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 27/38
© 2012 SAP AG. All rights reserved. 27This 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 .
SELECT
SUM(NETWR)
SUM(KURSK)
FROM CALC VIEW
22 – Multiple fact tables
NETWR KURSK
33 23
ROWNUM NETWR KURSK
1 20 10
2 13 13
SELECT SUM(NETWR),KURSK
FROM VIEWGROUP BY KURSK
Fact table
Use a Calculation View to
turn the Attribut e KHUSK
back into a Measure
Measure used as an
At tr ibute
Engine OLAP Query!from the Calculation
View
VBELN NETWR
1 10
2 10
3 13
Total 33
VBELN KURSK
1 10
2 10
3 13
Total 33
Warning!
Modeling measures as
attributes only works
in certain cases
VBRPVBAP
Incorrect Total!!!
Due to the measures having the same value. Aggregat ion removes dupli cate lines
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 28/38
© 2012 SAP AG. All rights reserved. 28This 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 .
SELECT
WERKS
SUM(NETWR)
FROM OLAP VIEW
GROUP BYWERKS
23 – Filters
Fact table
Note!
Filters are executed
independent of the Join
type and even though NO
fields are selected fromVBPA
67 Million 408 Million
JOIN FILTERS ResultINNER OFF 10 seconds
REFERENTIAL OFF .5 second
LEFT OUTER OFF .5 seconds
JOIN FILTERS ResultINNER ON 4 seconds
REFERENTIAL ON 4 seconds
LEFT OUTER ON 15 seconds
Suggested alternative modeling approach!
Create a Attribute View, add VBPA includ ing filters. Join fact tableVBAP with Attribute View. Left Outer Jo in executes in .5 seconds
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 29/38
© 2012 SAP AG. All rights reserved. 29This 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 .
SELECT MATNR,
SUM(NETWR_AGG,
SUM(NETWR_PROJ)
FROM CALC VIEW GROUP BY MATNR
24 – Aggregation Node
Note!
Difference in the amount of
data transferred when RAW
tables are used
Note!
No difference in data
transferred due to inherit
OLAP Aggregation
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 30/38
© 2012 SAP AG. All rights reserved. 30This 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 .
SELECT FLAG,
CUSTOMER,
YEAR, NETWRFROM CALC VIEW
25 – Multi Dimensional Disabled (Calculation View)
Note!
No intermediate results fo r
Union
CUSTOMER YEAR NETWR
1 2010 200
2 2010 300
SELECT CUSTOMER, YEAR,
SUM(NETWR) FROM AV
FLAG CUSTOMER YEAR NETWR
ACTUAL 1 2010 200
ACTUAL 2 2010 300
PLANNED 1 2010 210
PLANNED 2 2010 290
CUSTOMER YEAR NETWR
1 2010 210
2 2010 290
Note!
No measures, instead
measures defined as
attributes
Note!
Output node is not deployed
as a aggregation node but
instead a projection node
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 31/38
© 2012 SAP AG. All rights reserved. 31This 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 .
26 – Column Engine vs Row Engine
SELECTTO_DATE(DATE_SQL,'YYYY-MM-DD'),
SUM(NETWR)
FROM ANALYTICAL VIEW
GROUP BY DATE_SQL
Warning!
Query is processed by 2 engines. Rowengine will process DATE_SQL function
first, then transfer data to the Column
Engine. Depending on the amount of data
transferred it could severely impact
performance
When using Attribute, Analytical or Graphical Calculation Views the Row engine is not used;except if the SQL from the outside against these views contains elements that are not
natively supported by the Column engine.
The Explain Plan will indicate in what engine SQL queries executes.
Refer to the SAP HANA Database – Development Guide > Features of the Column Storage
Engine for supported Column store SQL elements.
SELECT
TO_DATE(DATE_SQL),SUM(NETWR)
FROM ANALYTICAL VIEW
GROUP BY DATE_SQL
Note!
Query is processed by Column engine
alone since the TO_DATE function without
parameters are natively supported
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 32/38
Thank You!
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 33/38
APPENDIX
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 34/38
© 2012 SAP AG. All rights reserved. 34This 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 .
Turn on the Python Trace file
• Tracing information writ ten to server trace file servertrace_ld9506_30003_000.py
• indexserver > pythontrace > trace > on
• indexserver > calcengine > trace_intermediate_results > yes
• indexserver > tracemodels > true
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 35/38
© 2012 SAP AG. All rights reserved. 35This 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 .
Diagnosis File location
• Tracing information writ ten to server trace file servertrace_ld9506_30003_000.py
• If the file is to large, make a copy and delete the file. Stop & Start the Index server
• Index server does not need to be restarted when changing the log file name
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 36/38
© 2012 SAP AG. All rights reserved. 36This 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 .
Example: WHERE clauses pushed down
Calculation View
Analytical View
WHERE clause
pushed down to
OLAP Engine
WHERE clause …
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 37/38
© 2012 SAP AG. All rights reserved. 37This 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 .
Example: WHERE clauses NOT pushed down
Analytical View
Excessive data
transferred from
OLAP to CALC
Engine
7/21/2019 0202 - Modeling - Best Practice.pdf
http://slidepdf.com/reader/full/0202-modeling-best-practicepdf 38/38
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
No part of this publication may be reproduced or transmitted in any form or for any
purpose without the express permission of SAP AG. The information contained
herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain
proprietary software components of other software vendors.
Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of
Microsoft Corporation.
IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5,
System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries,
zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390
Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6,
POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes,
BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF,
Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere,
Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM
Corporation.
Linux is the registered trademark of Linus Torvalds in the U.S. and other
countries.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or
registered trademarks of Adobe Systems Incorporated in the United States and/orother countries.
Oracle and Java are registered trademarks of Oracle.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and
MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®,
World Wide Web Consortium, Massachusetts Institute of Technology.
© 2011 SAP AG. All rights reserved.
SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjects
Explorer, StreamWork, SAP HANA, and other SAP products and services
mentioned herein as well as their respective logos are trademarks or registered
trademarks of SAP AG in Germany and other countries.
Business Objects and the Business Objects logo, BusinessObjects, Crystal
Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business
Objects products and services mentioned herein as well as their respective logos
are trademarks or registered trademarks of Business Objects Software Ltd.
Business Objects is an
SAP company.
Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere, and other
Sybase products and services mentioned herein as well as their respective logos
are trademarks or registered trademarks of Sybase, Inc. Sybase is an SAP
company.
All other product and service names mentioned are the trademarks of their
respective companies. Data contained in this document serves informational
purposes only. National product specifications may vary.
The information in this document is proprietary to SAP. No part of this document
may be reproduced, copied, or transmitted in any form or for any purpose without
the express prior written permission of SAP AG.