Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graeme Malcolm | Data Technology Specialist, Content Master

Similar presentations


Presentation on theme: "Graeme Malcolm | Data Technology Specialist, Content Master"— Presentation transcript:

1 Updating your Database Management Skills to Microsoft® SQL Server® 2014 Jump Start
Graeme Malcolm | Data Technology Specialist, Content Master Pete Harris | Learning Product Planner, Microsoft

2 Graeme Malcolm | ‏@graeme_malcolm
Microsoft Data Platform Specialist Consultant, trainer, and author since SQL Server 4.2 One of the world’s first MCSEs in SQL Server 2012 BI (Fairly) regular blogger at Longstanding partner with Microsoft Lead author for Microsoft Official Curriculum SQL Server 2014 courses Contributing author of Patterns and Practices Guide to Big Data Author of numerous training courses and Microsoft Press titles since SQL Server 7.0

3 Pete Harris | @SQLPete Learning Product Planner
Various roles at Microsoft since 1995

4 Join the MVA Community! Microsoft Virtual Academy
Free online learning tailored for IT Pros and Developers Over 1M registered users Up-to-date, relevant training on variety of Microsoft products

5 Course Topics Updating your Database Management Skills to Microsoft® SQL Server® 2014 01 | Making the Most of Memory 04 | Always On High Availability 02 | Mastering Your Data 05 | Managing Security 03 | Managing Data Quality 06 | SQL Server and the Cloud

6 Setting Expectations Target Audience
Database professionals familiar with SQL Server 2008 Suggested Prerequisites/Supporting Material Experience managing SQL Server 2008 databases Familiarity with Transact-SQL

7 The Road to SQL Server 2014 SQL Server 2014 2008 2010 2012 2014
Audit Compression Change Data Capture Data Collector Resource Governor Policy-Based Management PowerShell provider Spatial Data Filestream Data SQL Server 2008 R2 Multi-Server Admin Data-Tier Applications PowerPivot Report Builder 2.0 Master Data Services Prepared Instances StreamInsight SQL Server 2012 AlwaysOn High Availability Columnstore Indexes Contained databases User-Defined Server Roles Data Quality Services SSAS Tabular Mode SSIS Catalog SSRS Power View SSRS Data Alerts Deploy to SQL Azure SQL Server 2014 Windows Server 2008 Windows Server 2012 Windows Server 2012 R2 OS Windows Server 2008 R2 System Center 2007 System Center 2012 System Center 2012 R2 SQL Database Services (REST) SQL Azure Windows Azure SQL Database Azure Marketplace Data Market SQL Server in VMs Windows Azure HDInsight Office 2007 Data Mining Add-Ins (Excel) Office 2010 PowerPivot (Excel/SP) Office 2013 Power View(Excel) O365 Power BI Office Power Query Power Map Shared Queries Q&A MDS Add-in (Excel)

8 01 | Making the Most of Memory
Graeme Malcolm | Data Technology Specialist, Content Master Pete Harris | Learning Product Planner, Microsoft

9 Module Overview The Buffer Pool Extension Columnstore Indexes
Memory-Optimized Tables

10 Buffer Pool Extension Extends buffer cache to non- volatile storage
Improves performance for read- heavy OLTP workloads SSD devices are often more cost- effective than adding physical memory Simple configuration with no changes to existing applications. Data files (Disk) Buffer cache (RAM) Buffer pool extension (SSD) Pages Clean Pages

11 Demo: The Buffer Pool Extension
In this demonstration, you will see how to: Enable the Buffer Pool Extension Verify Buffer Pool Extension Configuration Disable the Buffer Pool Extension

12 Columnstore Indexes In-memory, compressed data in pages based on columns instead of rows Row Store Column Store ProductID OrderDate Cost 310 311 312 313 413.14 ProductID 310 311 312 313 314 315 316 317 318 319 320 321 OrderDate Cost 413.14 333.42 641.22 24.95 64.32 Data page 1000 ProductID OrderDate Cost 314 333.42 315 316 317 641.22 Data page 1001 Data page 2000 Data page 2001 Data page 2002

13 Types of Columnstore Index
Clustered Columnstore Indexes SQL Server 2014 Enterprise, Developer, and Evaluation Edition Only Includes all columns in the table Only index on the table Optimizes storage for compression and performance Updatable Non-Clustered Columnstore Indexes Includes some or all columns in the table Can be combined with other indexes Read-Only

14 Updating Clustered Columnstores
ProductID 310 311 312 313 OrderDate Cost 413.14 Deltastore ProductID OrderDate Cost 314 311 316 403.34 Columnstore A row-based deltastore stores interim changes New rows are inserted into the deltastore until the minimum rowgroup size is reached. Deleted rows in the deltastore are physically deleted. Columnstore data is marked as deleted, and space is reclaimed when the index is rebuilt. Updated rows in the deltastore are modified. Columnstore data is marked as deleted and a new row is added to the deltastore.

15 Updating Nonclustered Columnstores
Drop and recreate columnstore indexes Partition the table and switch in new rows Switched table must have a matching columnstore index Use Trickle Updating: Store only static data in the columnstore table Create a matching delta table for dynamic data rows Use UNION or Common Table Expressions to retrieve data Periodically move stabilized rows from the delta table to the columnstore table using one of the above techniques

16 Demo: Columnstore Indexes
In this demonstration, you will see how to: View Logical Reads for a Query Create a Non-Clustered Columnstore Index Create a Clustered Columnstore Index View Columnstore Index Metadata View Logical Reads for a Query If you did not perform the previous demonstrations in this module, start the MIA-DC and MIA-SQL virtual machines, and log on to MIA-SQL as ADVENTUREWORKS\Student with the password XXXXXXXXXXXXX. Then in the D:\Demofiles\Mod03 folder, right-click Setup.cmd and click Run as administrator. When prompted, click Yes. If it is not already open, start SQL Server Management Studio and connect to the MIA-SQL instance of SQL Server using Windows authentication. Open DWQuery.sql from the D:\Demofiles\Mod03 folder. Note that this script performs the following actions: Runs a query so that the required data is cached for future executions. Sets statistics options on so that details of the query execution can be retrieved. Runs the query again to retrieve the statistics. Sets the statistics options off again. Execute the script, and then wait until execution is complete and two results sets are displayed. On the Messages tab, note the elapsed time in the last line of the statistics report. Create a Non-Clustered Columnstore Index Open ColumnStoreIndex.sql from the D:\Demofiles\Mod03 folder. Select the code under the comment Create a non-clustered columnstore index and click Execute. That this script creates a non-clustered columnstore index on the FactProductInventory table. Return to the DWQuery.sql tab. Then execute the script, and wait until execution is complete and two results sets are displayed. On the Messages tab, note the elapsed time in the last line of the statistics report. This should be significantly lower than the previous execution. Return to the ColumnStoreIndex.sql tab and select the code under the comment Try to insert a row. Then click Execute. Note that an error occurs because you cannot modify a table on which a non-clustered columnstore index has been created. Create a Clustered Columnstore Index Select the code under the comment Drop the non-clustered columnstore index, existing clustered index, and foreign keys, and then click Execute. This drops all of the existing indexes on the table. Select the code under the comment Create a clustered columnstore index and click Execute. This creates a clustered columnstore index on the FactProductInventory table. On the Messages tab, note the elapsed time in the last line of the statistics report. This should still be significantly lower than the first execution. Return to the ColumnStoreIndex.sql tab and select the code under the comment Insert a row. Then click Execute. Note that you can insert data into a clustered columnstore index. View Columnstore Index Metadata Select the code under the comment View row groups and click Execute. Note that this code retrieves information about the columnstore index, and shows that the row you inserted is in a deltastore rowgroup, while the previously existing rows are all compressed in the columnstore.

17 Memory-Optimized Tables
Defined as C structs, compiled into DLLs, and loaded into memory Can be persisted as filestreams, or non-durable Do not apply any locking semantics Can be indexed using hash indexes Can co-exist with disk-based tables Can be queried using Transact-SQL Cannot include some data types, including text, image, and nvarchar(max) Do not support identity columns or foreign key constraints

18 Memory-Optimized Table Scenarios
Optimistic concurrency optimizes latch-bound workloads: Multiple concurrent transactions modify large numbers of rows A table contains “hot” pages Applications should handle conflict errors: Write conflicts Repeatable read validation failures Serializable validation failures Commit dependency failures

19 Creating Memory-Optimized Tables
Add a filegroup for memory-optimized data Create a memory-optimized table ALTER DATABASE MyDB ADD FILEGROUP mem_data CONTAINS MEMORY_OPTIMIZED_DATA; GO ADD FILE (NAME = 'MemData' FILENAME = 'D:\Data\MyDB_MemData.ndf') TO FILEGROUP mem_data; CREATE TABLE dbo.MemoryTable (OrderId INTEGER NOT NULL PRIMARY KEY NONCLUSTERED HASH WITH (BUCKET_COUNT = 1000), OrderDate DATETIME NOT NULL, ProductCode INTEGER NULL, Quantity INTEGER NULL) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA);

20 Memory-Optimized Indexes
Hash Indexes Rows assigned to buckets based on hashed key Multiple rows in the same bucket form a linked list Effective for equality predicates Query results are not sorted Range Indexes Latch free, in-memory B-Tree structure Effective for range scans, equality predicates, and inequality predicates CREATE TABLE tab1 (col1 INT NOT NULL INDEX h_idx NONCLUSTERED HASH WITH (BUCKET_COUNT = 100)) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_ONLY) CREATE TABLE tab2 (col1 INT NOT NULL INDEX r_idx NONCLUSTERED) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_ONLY)

21 Querying Memory-Optimized Tables
Query Interop Interpreted Transact-SQL Enables queries that combine memory-optimized and disk- based tables Native Compilation Stored procedure converted to C and compiled Access to memory-optimized tables only Native Compilation CREATE PROCEDURE… #define __in HRESULT hkp_(… Transact-SQL SELECT t1.col1, t3.col2 FROM Tab1 t1 JOIN Tab2 t2 ON t1.Col1 = t2.col1; Translate to C Compile to DLL Query Interop Memory-Optimized Tables Disk-Based Tables Tab1 Tab2 Tab3 Tab4

22 Creating Native Stored Procedures
Use the CREATE PROCEDURE statement NATIVE_COMPILATION option SCHEMABINDING option EXECUTE AS option BEGIN ATOMIC clause (isolation level and language) CREATE PROCEDURE INT WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER AS BEGIN ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT; LANGUAGE = 'us_English') DELETE dbo.OpenOrders WHERE CustomerID DELETE dbo.Customer WHERE CustomerID END;

23 Demo: Memory-Optimized Tables
In this demonstration, you will see how to: Enable Memory-Optimized Tables in a Database Create a Memory-Optimized Table Query Memory-Optimized Tables Create a Natively Compiled Stored Procedure View Memory-Optimized Table Statistics

24 Module Summary Make the most of memory
Use solid state storage to extend the buffer pool Use columnstore indexes for data warehouse workloads Use memory-optimized tables and native stored procedures for latch- bound workloads

25


Download ppt "Graeme Malcolm | Data Technology Specialist, Content Master"

Similar presentations


Ads by Google