ROLAP partitioning in MS SQL Server 2016

12
ROLAP PARTITIONING IN MS SQL SERVER 2016 Proof of concept with change queries, sample DB and VS project

Transcript of ROLAP partitioning in MS SQL Server 2016

Page 1: ROLAP partitioning in MS SQL Server 2016

ROLAP PARTITIONING IN MS SQL SERVER 2016Proof of concept with change queries, sample DB and VS project

Page 2: ROLAP partitioning in MS SQL Server 2016

2

WHAT IS INCLUDED IN THIS PRESENTATION

• .rar file on 6th slide with Visual Studio project and SQL, MDX and XMLA queries to see how MOLAP and ROLAP partitions work

• .rar has Sample OLTP working database• .rar contains Steps.txt file with steps how to configure permissions for SSAS service

account used by Cubes to get data and retrieve notification about changes in OLTP• Dimension partitioning• Defining slices for cube partitions

Page 3: ROLAP partitioning in MS SQL Server 2016

3

CONTENT:

1. Theory of partitioning and difference between ROLAP and MOLAP partitions in cube and dimension

2. 2. Use case with part of WWI (World Wide Importers) on SQL Server 2016 and VS 2015 project

3. Conclusion and other sources

Page 4: ROLAP partitioning in MS SQL Server 2016

4

1. THEORY OF PARTITIONING AND DIFFERENCE BETWEEN ROLAP AND MOLAP PARTITIONS IN CUBES

• To get fresh data in SSAS MOLAP cube processing is needed• This could take significant amount of time. Negative impact is a lag in displayed data • Solution – use ROLAP cube, which retrieves data directly from OLTP database without

processing• ROLAP cube is slower than MOLAP cube because data needs to go from OLTP to SSAS

database. See picture on next slide.• Partitions in cube could be separated into to MOLAP part and ROLAP part. MOLAP part

needs to be processed go get fresh data while ROLAP part goes directly to OLTP database to get data. • Such a cube, will take majority of data from MOLAP partition (like all years before) and

last year takes from ROLAP partition. To get desired results, ROLAP have smaller portion of data than MOLAP.

• Result – Fast cube (slower than pure MOLAP) but with actual data (actual for last year)

Page 5: ROLAP partitioning in MS SQL Server 2016

51. THEORY OF PARTITIONING AND DIFFERENCE BETWEEN ROLAP

AND MOLAP PARTITIONS IN CUBES

Page 6: ROLAP partitioning in MS SQL Server 2016

6

2. USE CASE WITH PART OF WWI (WORLD WIDE IMPORTERS) ON SQL SERVER 2016 AND VS 2015 PROJECT

• For demonstration of ROLAP partitioning use sample database in folder Databases + installation “Steps.txt”

• Be careful about permissions. To make ROLAP cube work is needed to setup correct permissions for SSAS Service account in OLTP Server with ALTER Trace permission. Without this, partition in cube will not get notification about changed data and will not know, that something changed in data.

ROLAP Proof of concept.zip

Page 7: ROLAP partitioning in MS SQL Server 2016

7

• ROLAP cubes have two partitions, divided according date dimension• Two cubes “AmountROLAPtableBinding” and “AmountROLAPqueryBinding” have

two partitions for each – one MOLAP (previous years) and one ROLAP (current year)

• Cube “AmountMOLAP” has one MOLAP partition• See queries in folder /Queries. Run “Measure Change Queries.sql”. There are

two inserts which write new sale of product with today’s date. Last select displays results, which should give MDX queries.

• MDX queries against ROLAP cubes give the same result as SQL query• MDX query against MOLAP cube gives the same result after processing

database by running XMLA script in “Process SSAS db.xmla” file. • Run change query again and see difference

2. USE CASE WITH PART OF WWI (WORLD WIDE IMPORTERS) ON SQL SERVER 2016 AND VS 2015 PROJECT

Page 8: ROLAP partitioning in MS SQL Server 2016

8

• Two scenarios exist for splitting data into partitionsa) Table binding – use separate views to get divided datab) Query binding – use one source and according SQL Query, SSAS divides

data into partitions. A “Where” clause in SQL query is mandatory in this case

• See cube’s “AmountROLAPtableBinding” partitions and their sources. Click on three dots and will see “Table binding” setup. For cube “AmountROLAPqueryBinding” is option “Query binding” picked up and appropriate SQL Query is provided.

• See “Slice” property for every partition. There is MDX query, which tells to SSAS engine which partition to touch to get data.

• Appropriate ROLAP partition is identified in SSAS engine running MDX query and SQL query goes to OLTP to get data.

• This is not happening automatically – notification about data change needs to come into SSAS engine. ROLAP mode is kind of MOLAP mode with enabled “Proactive caching” with zero latency and enabled notifications.

2. USE CASE WITH PART OF WWI (WORLD WIDE IMPORTERS) ON SQL SERVER 2016 AND VS 2015 PROJECT

Page 9: ROLAP partitioning in MS SQL Server 2016

9

• If notifications are not setup properly (alter trace permission is not granted to Service account on Server level and “db_datareader” on DB level) ROLAP partition works as MOLAP partition

• Last setup for partitions is “Slice” property. Slice provides full control about partitions, which will be used for MDX queries, and full speed of the source of data. It is officially recommended as “Good practice” to define slice property for every partition. But, MDX query in this property has several restrictions.

• We cannot use “Generate” or range “:” to generate data, what restricts significantly MDX queries to define parts of data.

• List of members could be generated dynamically during object processing by SSIS job.

• In this example I use simple dividing by years and list all years of Time dimension

2. USE CASE WITH PART OF WWI (WORLD WIDE IMPORTERS) ON SQL SERVER 2016 AND VS 2015 PROJECT

Page 10: ROLAP partitioning in MS SQL Server 2016

10

• Same steps are needed as for Measure partitioning until one bug in VS. • Go to dimension properties (not member properties), choose storage mode

ROLAP and proactive caching “Real-time ROLAP”. • But after successful deployment and processing of DB I get error in DB engine

running MDX query in SSMS. There is one setting in property “Error Configuration”. After changing dimension mode to ROLAP, VS automatically changes dimension’s “Error Configuration” property to “Custom”.

• This causes errors during running MDX queries. Change this property “Default” and process. MDXs should run without error now.

• After this change I changed “Error Configuration” property back to “Custom” and it works also.

2. USE CASE WITH PART OF WWI (WORLD WIDE IMPORTERS) ON SQL SERVER 2016 AND VS 2015 PROJECT

Page 11: ROLAP partitioning in MS SQL Server 2016

11

• To test ROLAP functionality in dimension Customers us second query in file “Dimension Change Queries.sql”.

• Updates change CustomerID from 83 to 10000 in source database. MDXs use CustomerID = 83, so there will be no result

• This change proves, that dimension “Customers” is in ROLAP mode so change in OLTP reflects immediately

• Change influences also MOLAP cube, because use the same ROLAP dimension “Customers”

2. USE CASE WITH PART OF WWI (WORLD WIDE IMPORTERS) ON SQL SERVER 2016 AND VS 2015 PROJECT

Page 12: ROLAP partitioning in MS SQL Server 2016

12

3. CONCLUSION AND OTHER SOURCES

• Benefits – it is possible to have actual data from not processed cube• This makes sense for large cubes, where processing take more time• Cons - changes in OLTP which does not fall in basket of ROLAP partition are

not reflected in these cubes until processing

• See article about how SSAS works with partitions and slice queries: http://sqljason.com/2012/01/set-slice-on-your-ssas-cube-partitions.html

• See link how to setup SSIS job to generate slice queries during cube processing https://msdn.microsoft.com/en-us/library/ms174764.aspx

• In case of interest about this area, help with configuration or comments please contact me via LinkedIn - “Andrej Zafka” or via email [email protected]

• Thank you for reading till end