27
In Memory OLTP SQL server 2014 Hekaton Engine Frederik Bogaerts

SQL Track: In Memory OLTP in SQL Server

Embed Size (px)

DESCRIPTION

With SQL server 2014, Microsoft introduced In-Memory OLTP, codename Hekaton. This technology contains revolutionary concepts for optimizing the performance of OLTP workloads via natively compiled stored procedures,memory optimized tables and much more. This session will give you an overview of the different aspects of In-memory OLTP and how this is integrated in the SQL server engine. By giving demo's we will show you what is (im)possible with this new feature and how this really can increase your database performance!

Citation preview

Page 1: SQL Track: In Memory OLTP in SQL Server

In Memory OLTP

SQL server 2014 Hekaton Engine

Frederik Bogaerts

Page 2: SQL Track: In Memory OLTP in SQL Server

Give me more

Page 3: SQL Track: In Memory OLTP in SQL Server

NSLOOKUP 127.0.0.0

Page 4: SQL Track: In Memory OLTP in SQL Server

Hekaton in a nutshell

Please ExplainWhy Demo

Page 5: SQL Track: In Memory OLTP in SQL Server

So long …

Page 6: SQL Track: In Memory OLTP in SQL Server

Hekaton – In Memory OLTPHash

Indexes

Memory Optimiz

ed Tables

Range Indexe

s

Latch-free

Page 7: SQL Track: In Memory OLTP in SQL Server

Hekaton Engine

Source: Microsoft.com

Page 8: SQL Track: In Memory OLTP in SQL Server

Prepare your databaseCreate Database Add memory optimized filegroup Add file to filegroup

Page 9: SQL Track: In Memory OLTP in SQL Server

Memory Optimized TablesCREATE TABLE [Customer]( [CustomerID] INT NOT NULL

PRIMARY KEY NONCLUSTERED HASH WITH (BUCKET_COUNT = 1000000),

[Name] NVARCHAR(250) NOT NULL, [CustomerSince] DATETIME NULL

INDEX [ICustomerSince] NONCLUSTERED)WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA);

Page 10: SQL Track: In Memory OLTP in SQL Server

Limitations No DML

no LOBs, no XML and no CLR data types

No Foreign Key or Check constraints

No UNIQUE indexes other than PK

Max 8 indexes

Page 11: SQL Track: In Memory OLTP in SQL Server

Data Structures

New Row Format

Versioning : Timestamps

No data page

containers

Row header Payload (table columns)

Begin Ts End Ts StmtId IdxLinkCount

8 bytes 8 bytes 4 bytes 2 + 2 (padding) bytes

8 bytes * (IdxLinkCount)

Source: Microsoft.com

Page 12: SQL Track: In Memory OLTP in SQL Server

Indexes

Buckets

Point Lookups

HashRange Scanning

BW-Tree

Non Clustered

Page 13: SQL Track: In Memory OLTP in SQL Server

Hash Indexes

Source: Microsoft.com

Page 14: SQL Track: In Memory OLTP in SQL Server

Range Indexes

Source: Microsoft.com

Page 15: SQL Track: In Memory OLTP in SQL Server

Natively Compiled Procs CREATE PROCEDURE [dbo].[InsertOrder] @id INT, @date DATETIME WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNERAS BEGIN ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N'us_english')

-- insert T-SQL hereEND

Page 16: SQL Track: In Memory OLTP in SQL Server

LimitationsOnly In MEM tables

No OUTER JOIN, no DISTINCT no OR, no subqueries, no CASE

Limited built-in functions

BUT: Fastest way!

Good news : Interface will be expanded in next version

Page 17: SQL Track: In Memory OLTP in SQL Server

T-SQL (Not) Supported

INTEROP

Truncate

Dynamic en keyset cursors

Cross database

Linked servers

Locking Hints – Isolation Levels

Merge

Page 18: SQL Track: In Memory OLTP in SQL Server

Garbage Collection

Multi Versioning Stale Rows Scans slow Bloathing memory

Page 19: SQL Track: In Memory OLTP in SQL Server

DiagnosticsAll starting with sys.dm_db_xtpDMO

• sys.dm_db_xtp_checkpoint_files• sys.dm_db_xtp_table_memory_stats• Sys.dm_db_xtp_index_stats

XEvents• From SYS.dm_xe_objects O JOIN SYS.dm.xe_packages P on O.package_guid = P.guid where P.name = ‘XtpEngine’

Perfomance Counters• From sys.dm_os_performance_counters where object_name like ‘XTP%’

Page 20: SQL Track: In Memory OLTP in SQL Server

Keep In MindData in memory at all times

Still using log files

Do not exceed 256 GB of InMem table

Page 21: SQL Track: In Memory OLTP in SQL Server

Going For Gold

Page 22: SQL Track: In Memory OLTP in SQL Server

Please ExplainWhy Demo

Page 23: SQL Track: In Memory OLTP in SQL Server
Page 24: SQL Track: In Memory OLTP in SQL Server

Follow Technet Belgium@technetbelux

Subscribe to the TechNet newsletteraka.ms/benews

Be the first to know

Page 25: SQL Track: In Memory OLTP in SQL Server

A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?

The SQL query found the table by doing a full scan of the other tables…

In the meanwhile, the waitress arrived at the table. Woohoow what a nice view…

Page 26: SQL Track: In Memory OLTP in SQL Server

Thank You!

Page 27: SQL Track: In Memory OLTP in SQL Server

Belgium’s biggest IT PRO Conference