| basel sql server 2014: in- memory oltp stéphane haby - stéphane savorgnano consultant dbi...

35
| Basel SQL Server 2014: In-Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Upload: meagan-gilbertson

Post on 01-Apr-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

| Basel

SQL Server 2014: In-Memory OLTPStéphane Haby - Stéphane SavorgnanoConsultantdbi services

Page 2: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Agenda

Agenda

IntroductionHow to process?Memory optimized objectsConcurrency controlDemoConclusion

Page 3: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

| Basel

Introduction

Chapter 1/6

Page 4: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Introduction

Stéphane SavorgnanoConsultantMobile +41 79 870 54 [email protected]

Stéphane HabyDelivery ManagerSenior ConsultantMobile +41 79 103 89 [email protected]

Page 5: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Introduction

dbi servicesExperts At Your Service 30 specialists in IT infrastructure Certified, experienced, passionate

Based In Switzerland 100% self-financed Swiss company More than CHF 3 mio. in sales

Leading In Infrastructure Services Over 70 customers in CH, D, & F 30 SLAs dbi FlexService signed

Page 6: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Introduction

Project HekatonDelivering the feature In-Memory OLTP Algorithms optimized for accessing in-memory data Optimistic concurrency control: eliminate logical locks due to automatic snapshot

isolation with multiple versioning Lock free and latch free structures to access dataStarted around 4 years ago

The goalBoost performance of OLTP workloads Using new memory optimized technology

Page 7: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Introduction

How?Take advantage of full memories and processor cores Hardware are more and more powerful

CPU with multiple cores RAM increase due to low price

Why?Stick to the market which wants Higher performance

More and more fast response (online betting, online credit-card transaction, online trading, …)

Page 8: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

| Basel

How to process?

Chapter 2/6

Page 9: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

How to process?

Find in your databasePerformance issues Tables with critical performances Stored Procedures

With complex logical calculations Huge tables crossover

Solve problemsCreation of a specific in-Memory FilegroupPut tables and Stored procedures with critical performances in-Memory

AdvantagesFast response(10x, 20x…)Access to those in-Memory objects is done as beforeCompletely integrated to SQL Server

Page 10: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

| Basel

Memory Optimized Objects

Chapter 3/6

Page 11: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Filegroup

Page 12: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized Objects

New kind of filegroup have been created To contain memory optimized objects Filegroup Container is first similar to filestream

Page 13: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized ObjectsInternal representation

Page 14: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Tables and Indexes

Page 15: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized Objects

Tables and indexes can be created by script as usualA new type of index appear: Hash index It is a non clustered index Need the option bucket_count to know the size of the index (twice the size of the

rows expected)

Page 16: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized Objects

Table creationWhen the script is executed A CREATE TABLE DDL code is generated This CREATE TABLE DDL is transformed in a C program This C program is compiled A DLL is produced The DLL is loaded in memory

Files created for each table:

Page 17: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized ObjectsHash Indexes>Use Hash function(f)

>Maps randomly values to buckets

>Defined in the system

>Bucket_count>Number of slot in the hash

index>Array of 8-byte memory

pointers

4567

0123

Hash mapping(with Bucket_count = 8):

f(Yann)

f(Greg)f(Steph)

f(Audi)

f(Mercedes), f(VW)

Hash Collision

s

Page 18: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized Objects

40, ∞Step

hAudi

Timestamps

NameChain ptrs CarMaque

Hash index on CarMaque

Hash index on name

80, ∞ Greg Mercedes

f(Greg)

f(Steph)f(Audi)

f(Mercedes)

Page 19: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized Objects

40, ∞Step

hAudi

Timestamps

NameChain ptrs CarMaque

Hash index on CarMaque

Hash index on name

80, ∞ Greg Mercedes

f(Audi)90, ∞ Yann Audi

f(Yann)

T90: Insert(Yann, Audi)

Page 20: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized Objects

40, ∞Step

hAudi

Timestamps

NameChain ptrs CarMaque

Hash index on CarMaque

Hash index on name

80, ∞ Greg Mercedes

90, ∞ Yann Audi

T120: Delete(Greg, Mercedes)

80, 120

Page 21: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized Objects

40, ∞Step

hAudi

Timestamps

NameChain ptrs CarMaque

Hash index on CarMaque

Hash index on name

80, ∞ Greg Mercedes

90, ∞ Yann Audi

T180: Update(Yann, Audi) to (Yann, Mercedes)

80, 120

180, ∞ Yann Mercedes

90, 180

f(Yann)

f(Mercedes)

Page 22: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized Objects

40, ∞Step

hAudi

Timestamps

NameChain ptrs CarMaque

Hash index on CarMaque

Hash index on name

T220: Garbage collector80, ∞ Greg Mercedes80, 120

180, ∞ Yann Mercedes

90, ∞ Yann Audi90, 180

f(Yann)

f(Mercedes)

f(Audi)f(Steph)

Page 23: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized Objects

Limitations on tables for version CTP1No foreign key and check constraintsNo identity (now available with CTP2, just (1,1))Cannot alter table, need to drop and recreate the tableCannot add or remove an index, need to drop and recreate tableNo LOB(Large Object) like nvarchar(max)Max size for a row is 8060 bytes(optimized for in–memory)No DML TriggersNo XML or CLR data types

Page 24: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Stored Procedures

Page 25: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized Objects

Stored procedure can be created by script with special argumentsNo alter procedure possible, need to drop and recreate the procedure

Page 26: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized Objects

When the script is executed A CREATE PROC DDL code is generated The query is optimized A C program is generated for CREATE PROC DLL This C program is compiled A DLL is produced The DLL is loaded in memory

Files created for each Stored procedure(same files than for a table)

Page 27: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Memory Optimized ObjectsHow to work with in-Memory tablesT-SQL

>Possibility to access in the same script in-memory and disk based tables

>Less efficient>But all T-SQL Surface

When to use>Adhoc queries>Reporting queries>Migration queries

Natively compile Stored Procedures

>Cannot access disk tables, only in-memory tables

>Very efficient>Limited T-SQL Surface(or, outer

join…)

When to use>OLTP style operations>Critical performance operations

Page 28: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

| Basel

Concurrency control

Chapter 4/6

Page 29: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Concurrency control

In-Memory table>Multi-version: each tables can

have multiple versions of each rows

>Transaction isolation level is snapshot based

>Transaction semantic is optimistic: always assume that a transaction is going to commit(no locks, no latches)

>Conflict detection to ensure isolation(no deadlocks)

Disk based table>Locking and blocking to

guaranty isolation(even with snapshot or read committed snapshot you use locking for write)

Page 30: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

| Basel

Demo

Chapter 5/6

Page 31: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

Demo

Page 32: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

| Basel

Conclusion

Chapter 6/6

Page 33: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

ConclusionNew memory optimized tables New hash indexesNew natively compiled stored proceduresBring best performanceMulti-versioned rows, snapshot based isolationOptimistics: no locking, conflict detection

T-SQL limitationsCannot alter in-memory tablesCannot alter natively compiled stored procedures

Page 34: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

ConclusionSQL Server 2014 web sitehttp://www.microsoft.com/en-us/sqlserver/sql-server-2014.aspx

SQL Server 2014 CPT2 downloadhttp://technet.microsoft.com/fr-fr/evalcenter/dn205290.aspx

SQL Server 2014 CTP2: In-Memory Advisor for Tables and Stored http://www.dbi-services.com/index.php?option=com_easyblog&view=entry&id=277&Itemid=82

Page 35: | Basel SQL Server 2014: In- Memory OLTP Stéphane Haby - Stéphane Savorgnano Consultant dbi services

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

© 2013 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.