50
Microsoft Confidential Many-To-Many dimensions relationships Yennifer Santos Premier Field Engineer Microsoft Corporation

Microsoft Confidential. We look at the world... with our own eyes

Embed Size (px)

Citation preview

Page 1: Microsoft Confidential. We look at the world... with our own eyes

Microsoft Confidential

Many-To-Many dimensions relationships

Yennifer SantosPremier Field EngineerMicrosoft Corporation

Page 2: Microsoft Confidential. We look at the world... with our own eyes

We look at the world... with our own eyes ...

Page 3: Microsoft Confidential. We look at the world... with our own eyes

And no matter what our perspective is...

Page 4: Microsoft Confidential. We look at the world... with our own eyes

We understand that people play the most important role

Page 5: Microsoft Confidential. We look at the world... with our own eyes

People interact, communicate and relate each other every day ...

Page 6: Microsoft Confidential. We look at the world... with our own eyes

They relate in a one to many relationships ...

Page 7: Microsoft Confidential. We look at the world... with our own eyes

On a one to one relationships ...

Page 8: Microsoft Confidential. We look at the world... with our own eyes

And in a many-to-many relationships ...

Page 9: Microsoft Confidential. We look at the world... with our own eyes

With all the pros and cons ... for each one of them

Page 10: Microsoft Confidential. We look at the world... with our own eyes

So for the SSAS …... Cube perspective of the world ......

Page 11: Microsoft Confidential. We look at the world... with our own eyes

The way relationships are build…is extremelly important

Page 12: Microsoft Confidential. We look at the world... with our own eyes

Specially when we are talking about M2M relationships

Page 13: Microsoft Confidential. We look at the world... with our own eyes

Typical scenario

Page 14: Microsoft Confidential. We look at the world... with our own eyes

M2M scenario concepts

14

Data measure group

M2M dimension

Intermediate measure group

Intermediate dimension

Page 15: Microsoft Confidential. We look at the world... with our own eyes

M2M scenario

Page 16: Microsoft Confidential. We look at the world... with our own eyes

What’s up with M2M relationships in SSAS?

16

Query

By M2M Dim

IN MEMORY INNER JOIN

Page 17: Microsoft Confidential. We look at the world... with our own eyes

What’s up with M2M relationships in SSAS?

As the data size of the records in the join increasesThe performance of the run-time join in SSAS suffers

17

IN MEMORY INNER JOIN

Page 18: Microsoft Confidential. We look at the world... with our own eyes

Query performance with M2M

Query performance in SSAS is intrinsically and linearly tied to the size of the data being joined between

Data andIntermediate measure groups

18

Page 19: Microsoft Confidential. We look at the world... with our own eyes

What to do to improve query performance?

There are 3 optimization techniques:Defining aggregationsPartitioningMatrix relationship

19

Page 20: Microsoft Confidential. We look at the world... with our own eyes

Defining aggregations optimization technique

What is an aggregation?Pre-calculated summary of data that SSAS uses to enhance query performanceMoves the calculation to the processing phaseSummarizes measures by a combination of dimension attributes

20

1st

Page 21: Microsoft Confidential. We look at the world... with our own eyes

Defining aggregations optimization technique

Aggregations Work by reducing the number of records that the storage engine needs to scan from disk in order to satisfy a queryProvides a significant benefit only if the size of the aggregation is significantly smaller than the size of the original table

21

Page 22: Microsoft Confidential. We look at the world... with our own eyes

Defining aggregations optimization technique

Where to define aggregations in a M2M scenario?

22

Page 23: Microsoft Confidential. We look at the world... with our own eyes

Defining aggregations optimization technique

Data measure group aggregations for M2M queries

Include in the aggregation the granularity attribute of all dimensions that join with the intermediate measure groupDo not include the attribute from the M2M dimension (occurs at query time as part of the run-time join)

23

X

Page 24: Microsoft Confidential. We look at the world... with our own eyes

Defining aggregations optimization technique

BenefitsThe benefit is directly related to the size of this aggregation compared to the size of the data measure groupAn aggregation whose size is >=1/3 the size of the facts themselves is not considered to be useful

24

Page 25: Microsoft Confidential. We look at the world... with our own eyes

Defining aggregations optimization technique

Intermediate measure group aggregations for M2M queries

Include in the aggregation the granularity attribute of the dimensions in the intermediate measure group that relates to the data measure group The attribute in the dimension that you wish to aggregate

25

Page 26: Microsoft Confidential. We look at the world... with our own eyes

Defining aggregations optimization technique

BenefitsThe benefit is directly related to the resulting size of the aggregation compared to the size of intermediate measure group

26

Page 27: Microsoft Confidential. We look at the world... with our own eyes

Partitioning optimization technique

PartitioningEnables SSAS to retrieve data from only a portion of data in a measure groupParallelize data retrieval when data must be retrieved from multiple partitions

27

2nd

Page 28: Microsoft Confidential. We look at the world... with our own eyes

Partitioning optimization technique

Where to define partitions in a M2M scenario?

28

Page 29: Microsoft Confidential. We look at the world... with our own eyes

Partitioning the data measure group

Data measure groupThe data measure group should generally be partitioned by the same dimension attribute members as the intermediate measure group

29

Page 30: Microsoft Confidential. We look at the world... with our own eyes

Partitioning the intermediate measure group

Intermediate measure groupYou must relate the partitioning dimensions to the intermediate measure Benefit

Reduces the data size used by the run-time join between intermediate and data measure groupsWhen the M2M query can be resolved from only a few (or one) partitions

30

Page 31: Microsoft Confidential. We look at the world... with our own eyes

Partitioning the intermediate measure group

If the M2M query must be resolved by retrieving data from many or all partitions

The technique provides little or no value and may even increase response times

31

Page 32: Microsoft Confidential. We look at the world... with our own eyes

Partitioning the intermediate measure group

Design paternThe intermediate measure group must

Be partitioned by one or more common dimensions used in queriesBe related to each dimension that is used for partitioning

The intermediate fact table must Contain the dimension surrogate key

That is used for the measure group partitioningTo relate with the dimension

32

Page 33: Microsoft Confidential. We look at the world... with our own eyes

Matrix relationship optimization technique

Increases M2M query performance by reducing the size of the run-time join

Uses a process of compression to eliminate unnecessary repetitiveness in the intermediate fact tableCollapses the size of the intermediate fact table

33

3rd

Page 34: Microsoft Confidential. We look at the world... with our own eyes

Matrix relationship optimization technique

Two phases:Compression and creation of the matrix keyImplementing the matrix optimization

34

Page 35: Microsoft Confidential. We look at the world... with our own eyes

Compression and creation of the matrix key

Creates a compressed intermediate fact table by taking the following steps:

Identify common dimension member combinations in the intermediate fact table Each set of common dimension member combinations is assigned a surrogate key (matrix key)Repeated combinations are eliminated

35

Page 36: Microsoft Confidential. We look at the world... with our own eyes

Compression and creation of the matrix key

36

Page 37: Microsoft Confidential. We look at the world... with our own eyes

Implementing the matrix optimization

Requires changes to aspects of the M2M relationship at the following levels:

The relational data warehouse implementation levelThe cube design levelThe ETL implementation level

37

Page 38: Microsoft Confidential. We look at the world... with our own eyes

Relational Datawarehouse

38

Page 39: Microsoft Confidential. We look at the world... with our own eyes

Relational Datawarehouse

Matrix dimension table creation

39

Page 40: Microsoft Confidential. We look at the world... with our own eyes

Relational Datawarehouse

Requires an intermediate fact table that relates the M2M dimensions to the base fact through the matrix key

Will have the matrix key column and one or more dimension key columns

40

Page 41: Microsoft Confidential. We look at the world... with our own eyes

Relational Datawarehouse

Add the Matrix Key column to the base fact table

41

Page 42: Microsoft Confidential. We look at the world... with our own eyes

Cube design

Works in the same way that any M2M dimension relationshipThe difference is

Shared dimension between the base measure group and the intermediate measure group is the matrix dimension, rather than the fact dimension

42

Page 43: Microsoft Confidential. We look at the world... with our own eyes

Cube design

In Data Source View, add two tables for

Matrix dimension New intermediate fact table

43

Page 44: Microsoft Confidential. We look at the world... with our own eyes

Cube design

Add a new SSAS database dimension based on the matrix dimension tableAdd this dimension to the cube that contains the base measure group

44

Page 45: Microsoft Confidential. We look at the world... with our own eyes

Cube design

Add a new SSAS measure group to act as the intermediate measure group for resolving the M2M relationships Remove the existing

Sales Reasons measure group

45

Page 46: Microsoft Confidential. We look at the world... with our own eyes

Cube design

Define the Dimension Usage to associate the dimension tables to the measure groups

Both the base and intermediate measure group must have a direct relationship to the matrix dimension

46

Page 47: Microsoft Confidential. We look at the world... with our own eyes

Cube design

The intermediate measure group also needs a direct relationship to the dimension or dimensions that participate in the M2M relationshipThe dimensions referenced in the second point must also be related to the base measure group

47

Page 48: Microsoft Confidential. We look at the world... with our own eyes

ETL implementation level

The ETL involvesUpdating the relational data warehouse tables with new matrix relationships Associating the fact tables to the matrix dimensions

48

Page 49: Microsoft Confidential. We look at the world... with our own eyes

Matrix relationship

The general guidelines are:Adding new key concatenation strings to the matrix dimension table for new records being added to the fact tableAdding the matrix dimension key associated with each transaction ID to the base fact tableAdding the key of the matrix dimension with each M2M dimension key record

49

Page 50: Microsoft Confidential. We look at the world... with our own eyes

Questions and Answers

50