Sie sind auf Seite 1von 25

Graeme Malcolm | Data Technology Specialist, Content Master

Pete Harris | Learning Product Planner, Microsoft


Graeme Malcolm | @graeme_malcolm
Microsoft Data Platform Specialist
Consultant, trainer, and author since SQL Server 4.2
One of the worlds first MCSEs in SQL Server 2012 BI
(Fairly) regular blogger at www.contentmaster.com
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
Pete Harris | @SQLPete

Learning Product Planner
Various roles at Microsoft since 1995

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
Join the MVA Community!
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
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

The Road to SQL Server 2014
SQL Server 2008 R2
Multi-Server Admin
Data-Tier Applications
PowerPivot
Report Builder 2.0
Master Data Services
Prepared Instances
StreamInsight
2008 2010 2012 2014
SQL Server 2008
Audit
Compression
Change Data Capture
Data Collector
Resource Governor
Policy-Based
Management
PowerShell provider
Spatial Data
Filestream Data
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

SQL Azure SQL Database Services
(REST)
Windows Azure SQL Database
SQL Server in VMs
A
z
u
r
e

Office 2013
Power View(Excel)
O
f
f
i
c
e

Power Query
Power Map
O365 Power BI Office 2010
PowerPivot (Excel/SP)
MDS Add-in (Excel)
Marketplace Data Market
Office 2007
Data Mining Add-Ins (Excel)
Windows Server 2008
O
S

Windows Server 2008 R2
Windows Server 2012 Windows Server 2012 R2
System Center 2007 System Center 2012 System Center 2012 R2
Windows Azure HDInsight
Shared Queries
Q&A
01 | Making the Most of Memory
Graeme Malcolm | Data Technology Specialist, Content Master
Pete Harris | Learning Product Planner, Microsoft
The Buffer Pool Extension
Columnstore Indexes
Memory-Optimized Tables
Module Overview
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
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

Columnstore Indexes
In-memory, compressed data in pages based on
columns instead of rows

ProductID OrderDate Cost
310 20010701 2171.29
311 20010701 1912.15
312 20010702 2171.29
313 20010702 413.14
Data page 1000
ProductID OrderDate Cost
314 20010701 333.42
315 20010701 1295.00
316 20010702 4233.14
317 20010702 641.22
Data page 1001
ProductID
310
311
312
313
314
315
316
317
318
319
320
321
Data page 2001
OrderDate
20010701

20010702


20010703




20010704

Data page 2000 Data page 2002
Cost
2171.29
1912.15
2171.29
413.14
333.42
1295.00
4233.14
641.22
24.95
64.32
1111.25
Row Store Column Store
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

Updating Clustered Columnstores
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.

ProductID
310
311
312
313
OrderDate
20010701
20010702
Cost
2171.29
1912.15
2171.29
413.14
ProductID OrderDate Cost
314 20010701 2198.56
311 20010701 1919.10
316 20010702 403.34
Columnstore
Deltastore
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


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

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
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

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
ALTER DATABASE MyDB
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);
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)
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

Memory-Optimized
Tables
Disk-Based
Tables
Tab1 Tab2 Tab3 Tab4
Transact-SQL
SELECT t1.col1, t3.col2
FROM Tab1 t1
JOIN Tab2 t2
ON t1.Col1 = t2.col1;
Query Interop
Native Compilation
CREATE PROCEDURE



#define __in
HRESULT hkp_(



0110101101
Translate to C
Compile to DLL
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 dbo.DeleteCustomer @CustomerID INT
WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER
AS
BEGIN ATOMIC WITH
(TRANSACTION ISOLATION LEVEL = SNAPSHOT;
LANGUAGE = 'us_English')
DELETE dbo.OpenOrders WHERE CustomerID = @CustomerID
DELETE dbo.Customer WHERE CustomerID = @CustomerID
END;
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

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
2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics 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.

Das könnte Ihnen auch gefallen