Presentation is loading. Please wait.

Presentation is loading. Please wait.

Before we begin Goals Non-goals (but feel free to ask questions)

Similar presentations


Presentation on theme: "Before we begin Goals Non-goals (but feel free to ask questions)"— Presentation transcript:

1 Before we begin Goals Non-goals (but feel free to ask questions)
9/17/ :59 PM Before we begin Goals Columnstore fundamentals Health and monitoring Performance and scalability Loading patterns and tools Non-goals (but feel free to ask questions) Every detail about SQL Data Warehouse and columnstore Columnstore deep dive (deeper than design and behavior) Read every bullet in every slide Pre-requisites Working knowledge of SQL Server and SQL Data Warehouse © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

2 Getting peak performance from your SQL Data Warehouse columnstore
9/17/ :59 PM BRK4016 Getting peak performance from your SQL Data Warehouse columnstore Shivani Gupta, Joe Yong SQL Data Warehouse Program Management © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

3 Agenda Azure SQLDW Columnstore Primer Columnstore Health
9/17/ :59 PM Agenda Azure SQLDW Columnstore Primer Terminology & Operations (Insert, Update, Delete, Scan) Distributions and Partitions Columnstore Health Pressures (memory and dictionary) Monitoring for health ELT/ETL Patterns and Guidance Maximizing row group quality Partitioning guidance, Ordering Secondary B-Tree Indexes Data Loading Tools Polybase, SSIS, Data Factory, BCP © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

4 Azure SQL Data Warehouse
9/17/ :59 PM Full managed, data warehouse as a service Massively Parallel Processing (MPP) architecture Separation of storage and compute Industry leading SQL Server in each compute node Control Node Compute SQL DB Blob storage [WASB(S)] Massively Parallel Processing (MPP) Engine Azure Infrastructure and Storage Application or User connection Data Loading (PolyBase, ADF, SSIS, REST, ODBC, ADF, AZCopy) DMS © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

5 SQLDW Columnstore Primer
9/17/ :59 PM SQLDW Columnstore Primer © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

6 Columnstore Index: Why?
9/17/2018 Columnstore Index: Why? Data stored as rows Data stored as columns C5 C1 C2 C3 C4 rowgroup Ideal for OLTP Frequent read/write on small set of rows Ideal for Data Warehouse Analytics on large number of rows segment Improved compression: Data from same domain compress better Reduced I/O: Fetch only columns needed Improved Performance: More data fits in memory Optimized for CPU utilization Batch Mode Execution Vector Processing © 2015 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

7 Terminology Row group Column Segment Dictionary Metadata
9/17/ :59 PM Terminology 1 million row “row group” Row group Set of rows handled together, usually 1M Column Segment Values from one column of the row group Dictionary Encoding for string columns to integers Primary dictionary: shared across row segments Secondary dictionary: local to segment (max 1) Metadata Min,max values for segment elimination dictionaries primary secondary Column Segments metadata Min Max Col 1 val Col1 val Col 2 val © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

8 9/17/ :59 PM Load/Insert Batch inserts >= 100K rows go directly to compressed row groups Row groups can be trimmed pre- maturely under memory pressure. Batch inserts < 100k rows go to delta row group (which is a B- tree). Delta RGs are closed after 1 M rows. Tuple Mover moves closed delta RGs to compressed row groups. C1 C2 C3 Delta RGs Closed Open Tuple Mover Batch Size < 100k Batch Size >= 100k Compressed RGs © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

9 DML – delete and update Rows in delta stores are deleted directly
Rows in compressed row groups are not removed Their locators are tracked in the delete bitmap Update = delete + insert Delete bitmap

10 Scan Scans need to combine data from compressed row groups, delta stores and delete bitmaps to produce correct results Segment metadata used to eliminate row groups that do not qualify

11 Column Store in SQLDW 60 Distributions
9/17/ :59 PM Column Store in SQLDW 60 Distributions Each Distribution has its own Columnstore per table Multiple row groups per Columnstore © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

12 9/17/ :59 PM Partitioning Each distribution table partitioned N-ways. Total number of Columnstores = 60 * N CREATE TABLE [cso].[FactOnlineSales_PTN] ( [OnlineSalesKey] int NOT NULL , [DateKey] datetime NOT NULL , [StoreKey] int NOT NULL , [ProductKey] int NOT NULL , [CurrencyKey] int NOT NULL , [SalesQuantity] int NOT NULL , [SalesAmount] money NOT NULL , [UnitPrice] money NULL ) WITH ( CLUSTERED COLUMNSTORE INDEX , DISTRIBUTION = HASH([ProductKey]) , PARTITION ( [DateKey] RANGE RIGHT FOR VALUES ' :00:00.000‘ ,' :00:00.000' ; © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

13 Partitioning and Column Store in SQLDW
Table is defined with 2- way partitioning Each distribution’s data split into 2 partitions 2-way partitioning => 120 total Columnstores

14 Columnstore DMVs sys.pdw_nodes_column_store_row_groups
State of various row groups (open, closed, compressed) Total rows sys.pdw_nodes_column_store_segments Encoding used Dictionary id Min,max metadata sys.pdw_nodes_column_store_dictionaries On disk dictionary size

15 Demo: Primer Concepts

16 Columnstore Health

17 What determines scan performance?
Size of compressed row groups (aka rowgroup quality) Compression quality decreases with fewer rows Per row overhead of ancillary structures increases with fewer rows 1M rows per row group ideal 100,000 rows per row group acceptable < 10,000 abysmal. Disallowed now. Number of rows in delta stores Delta store is scanned row by row Small batch inserts end up in delta stores Singleton inserts end up in delta stores Higher DOP increases number of delta stores Size of Delete Bitmap Larger delete bitmap implies more time spent merging Large amount of delete and/or update activity grows delete bitmap

18 Factors affecting Row Group Quality
Available Rows 1. Load Batch Size 2. Partitioning Premature Trimming 1. Memory Pressure 2. Dictionary Pressure

19 Understanding Memory Pressure
Memory Required for quality row groups Target rows in the rowgroup (ideal is 1,048,576 = ~1 million rows per rowgroup) Fixed overhead #columns in the table #short string character typed columns (string data types of <=32 bytes) #long string character typed columns (string data types of >32 bytes) See details in rowgroup memory Memory Available to build row groups SLO of SQL Data Warehouse User’s Resource Class Complexity of load query Partitioning Degree of Parallelism Trimming occurs if Required > Available

20 Est. mem grant example #1: 10 column table

21 Memory Management (MB per distribution)
Service admin account

22 Degree of Parallelism (DOP)
Statement memory grant divided b/w parallel workers Use hint to force serial execution for CTAS (if needed) Create Table MyFactSalesQuota as Select * from FactSalesQuota OPTION(MAXDOP 1); < DWU 2000 – DOP 1 DWU – DOP 2 DWU – DOP 3 DWU – DOP 6

23 Dictionary Pressure High cardinality (distinct values) Wide strings
MAX Dictionary size 16MB in memory DMV Dictionary size Size on disk On disk size < In memory size

24 DMV for Columnstore Health
sys.dm_pdw_nodes_db_column_store_row_group_physical_stats Row Group State No of rows Trim Reason More details at

25 Demo: Columnstore Health

26 ELT/ETL Patterns and Guidance

27 ELT for maximizing scan performance
Sizing batch loads Partitioning Guidance Using Correct Resource Class Working around Dictionary Pressure Judicious use of updates and deletes Secondary B-Tree Indexes (NCI): needle-in-haystack queries How to improve segment elimination

28 Sizing Batch Loads Target >100,000 per columnstore in each load.
With no partitions, this means > 100,000 * 60 rows (~6 million) rows per CTAS or bulk insert With 4 partitions , this means > 100,000 * 60 * 4 (~24 million) rows per CTAS or bulk insert Ideally 1 million per Columnstore in each load With no partitions, this means > 1,000,000 * 60 rows (~60 million) rows per CTAS or bulk insert With 4 partitions , this means > 1,000,000 * 60 * 4 (~240 million) rows per CTAS or bulk insert

29 Batching trickle loads
Scenario: 100,000 rows per Columnstore, no partitions 6,000,000+ rows required for each batch load 500 Rows/Sec 1000 2000 Load threshold exceeded (hours) <3.5 hours < 2 hours < 1 hour

30 Partitioning Guidance
Rowgroups cannot cross partition boundaries Over-partitioning impacts row group quality Over-partitioning impacts compression Make sure your targeted data set allows for at least 6 million rows per partition. Ideally 60 million rows per partition! Partitioning impacts memory grant

31 Using Correct Resource Class
Compute memory required for quality row groups Memory guidance for Columnstore Use views provided. Grant sufficient memory Use correct resource class (usually not smallrc) Scale DWU if needed Keep load query simple – stage to a Heap/CI if needed Force serial execution if needed Don’t Over Allocate Resource Class Does impact concurrency (especially if multiple ELT jobs scheduled in parallel)

32 Working around Dictionary Pressure
Isolate problematic string columns into a separate table  Optimize column types where possible (e.g. use varchar(36) instead of nchar(255), smallint instead of nvarchar(4000)

33 Judicious use of Updates and Deletes
Use Heap/CI staging tables for transformations Alter Index Reorganize/Rebuild to defragment Reorganize is lighter weight and online Rebuild is heavy weight and offline

34 Secondary B-Tree Indexes (NCI)
Needle in a haystack queries (equality or short range) create index l_orderkeynci on lineitem(l_orderkey); select l_orderkey, l_returnflag, l_linestatus from lineitem where l_orderkey = ; Runs in under a second on 1TB TPC-H data BTREE (NCI) Delete bitmap Delta RGs Compressed RGs

35 Real world usage of NCI - Yammer
Run a DW 6000 Track all user activity to A/B test every new feature Fact Events – 300 billion rows (~40TB) Built NCI on UserId Query went from 10+ hours to < 5mins: SELECT TOP 1000 * FROM fact_events WHERE user_id=' '

36 Segment Elimination Min, max metadata used to filter out segments
Columnstore is not ordered Helps if data arrives naturally ordered e.g. timestamp Index Rebuild will not keep ordering intact Min Max Col 1 val Col1 val Col 2 val

37 Ordered CCI for improved segment elimination
(Date) CCI Partition Switch ALTER INDEX REBUILD compresses across rowgroups Removes any manual ordering from CCI

38 Data Loading Tools

39 Data Loading Options PolyBase SSIS* ADF BCP SQLBulkCopy API
Attunity Cloudbeam ASA/Storm** Method Performance PolyBase SSIS ADF BCP SQL Bulkcopy Rate Rate increases with higher DWU Yes Yes* No Rate increases with more concurrent loads Fastest Slowest * With SSIS Azure Feature Pack June 2017 or newer ** Not a good idea

40 Single gated client loading with SSIS data flows (before)
Using SSIS, customers can create data flows with ADO.NET/OLEDB Destination to load data into Azure SQL DW Similar to loading data into Azure SQL DB/SQL Server This method has two bottlenecks on the single SSIS-running machine and Control node

41 Single gated client loading with SSIS data flows (before)
Customers can also execute parallel loads with multiple SSIS-running machines by Divide input data into multiple sources Load concurrently into separate temporary tables Switching them in into partitions of the full final table Overall throughput is still limited by Control node

42 Parallel loading with PolyBase – T-SQL script
Configure the credentials to access your Azure Blob Storage CREATE DATABASE SCOPED CREDENTIAL AzureStorageCredential WITH IDENTITY = 'user', SECRET = '<azure_storage_account_key>'; Define the data source in your Azure Blob Storage with previously configured credentials CREATE EXTERNAL DATA SOURCE AzureStorage WITH ( TYPE = HADOOP, LOCATION = CREDENTIAL = AzureStorageCredential); Define the file format of your input data CREATE EXTERNAL FILE FORMAT TextFile WITH ( FORMAT_TYPE = DelimitedText, FORMAT_OPTIONS(FIELD_TERMINATOR = ','));

43 Parallel loading with PolyBase – T-SQL script
Define the external table for your input data CREATE EXTERNAL TABLE dbo.DimDate2External ( DateId INT NOT NULL, CalendarQuarter TINYINT NOT NULL, FiscalQuarter TINYINT NOT NULL) WITH ( LOCATION='/datedimension/', DATA_SOURCE=AzureStorage, FILE_FORMAT=TextFile); Load the external table from your Azure Blob Storage into Azure SQL DW CREATE TABLE dbo.DimDate2 WITH ( CLUSTERED COLUMNSTORE INDEX, DISTRIBUTION = ROUND_ROBIN) AS SELECT * FROM [dbo].[DimDate2External];

44 Parallel loading with PolyBase (with Azure feature pack)
Create Execute SQL task that triggers PolyBase to load data into Azure SQL DW, leveraging MPP architecture Throughput is not limited by Control node; scales out based on DWU level

45 Parallel loading with PolyBase
Parallel loading with PolyBase is the recommended method to load large volumes of data into SQL DW This requires users to manually create/deploy/run multiple tasks on SSIS and/or write T-SQL scripts Create/deploy/run transformation tasks to convert your input data into supported formats if necessary Create/deploy/run Azure Blob Upload Task to load it into Azure Blob Storage Create/deploy/run Execute SQL Task to convert it into external table(s) and trigger PolyBase to load them into Azure SQL DW Create/deploy/run clean-up tasks if necessary We have released Azure SQL DW Upload Task to automate most of these tasks (2 – 4) Leverage existing SSIS expertise Relieves customers from the “burden” of writing T-SQL script Azure Blob Storage SQL DW Cloud On-Premise SQL Server Flat File SSIS Machine 1. Export to a flat file 2. Upload to Azure Blob 3. Create external tables and trigger PolyBase to load them 4. Clean up staging area

46 Key takeaways

47 Wrap Up: Key Takeaways Columnstore behaviour is very different from row store Loading methods and efficiency matter a lot Monitor and maintain Columnstore health for better query performance Assess guidance and ELT patterns for your environment and implement for maximum performance, IF appropriate Picking the right loading tools can make a BIG difference

48 Please evaluate this session
Tech Ready 15 9/17/2018 Please evaluate this session From your Please expand notes window at bottom of slide and read. Then Delete this text box. PC or tablet: visit MyIgnite Phone: download and use the Microsoft Ignite mobile app Your input is important! © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

49 9/17/ :59 PM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Download ppt "Before we begin Goals Non-goals (but feel free to ask questions)"

Similar presentations


Ads by Google