Presentation is loading. Please wait.

Presentation is loading. Please wait.

Project “Hekaton” adds in-memory technology to boost performance of OLTP workloads in SQL Server.

Similar presentations


Presentation on theme: "Project “Hekaton” adds in-memory technology to boost performance of OLTP workloads in SQL Server."— Presentation transcript:

1

2

3 Project “Hekaton” adds in-memory technology to boost performance of OLTP workloads in SQL Server

4

5 CREATE TABLE [Customer]( [CustomerID] INT NOT NULL PRIMARY KEY NONCLUSTERED HASH WITH (BUCKET_COUNT = ), [Name] NVARCHAR(250) NOT NULL INDEX [IName] HASH WITH (BUCKET_COUNT = ), [CustomerSince] DATETIME NULL ) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA); This table is memory optimized This table is durable Secondary Indexes are specified inline Hash Index

6 CREATE TABLE DDLCode generation and compilationTable DLL producedTable DLL loaded

7 90,150 Susan Bogota 50, ∞ JanePrague 100, 200 JohnParis 200, ∞ JohnBeijing TimestampsNameChain ptrsCity Hash index on City Hash index on Name Garbage Collection Removes Unused Rows

8

9

10 CREATE PROCEDURE DATETIME WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER AS BEGIN ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = 'us_english') -- insert T-SQL here END This proc is natively compiled Native procs must be schema-bound Atomic blocks Create a transaction if there is none Otherwise, create a savepoint Execution context is required Session settings are fixed at create time

11 CREATE PROC DDLQuery optimizationCode generation and compilationProcedure DLL producedProcedure DLL loaded

12 Accessing Memory Optimized Tables Natively Compiled Procs – Access only memory optimized tables – Maximum performance – Limited T-SQL surface area When to use – OLTP-style operations – Optimize performance critical business logic Interpreted T-SQL Access (InterOP) – Access both memory- and disk-based tables – Less performant – Virtually full T-SQL surface When to use – Ad hoc queries – Reporting-style queries – Speeding up app migration – Eliminating Latch Contention

13

14

15

16

17 TimeTransaction T1 (SNAPSHOT)Transaction T2 (SNAPSHOT) 1BEGIN 2 3UPDATE t SET c1=‘bla’ WHERE c2=123 4UPDATE t SET c1=‘bla’ WHERE c2=123 (write conflict) First writer wins

18

19 Disk-based tablesMemory-optimized tables Tab1TabnTab1Tabm Regular Tx contextHekaton Tx context

20 Disk-basedMemory optimizedUsage recommendations READCOMMITTEDSNAPSHOT Baseline combination – most cases that use READCOMMITTED today READCOMMITTEDREPEATABLEREAD/ SERIALIZABLE Data migration Hekaton-only Interop REPEATABLEREAD/ SERIALIZABLE SNAPSHOT Memory-optimized table access is INSERT-only Useful for data migration and if no concurrent writes on memory-optimized tables (e.g., ETL) Disk-basedMemory optimized SNAPSHOT Any isolation level REPEATABLEREAD/ SERIALIZABLE REPEATABLEREAD/ SERIALIZABLE Supported isolation level combinations (V1) Unsupported isolation level combinations (V1)

21

22

23

24

25 CREATE PROCEDURE type2,... AS BEGIN END

26 CREATE PROCEDURE type2,... AS BEGIN INT = 10 WHILE > 0) BEGIN END

27 CREATE PROCEDURE type2,... AS BEGIN INT = 10 WHILE > 0) BEGIN BEGIN TRY = 0 END TRY BEGIN CATCH -= 1 END CATCH END

28 CREATE PROCEDURE type2,... AS BEGIN INT = 10 WHILE > 0) BEGIN BEGIN TRY = 0 END TRY BEGIN CATCH -= 1 IF > 0 AND error_number() in (41302, 41305, 41325, 41301, 1205)) IF ROLLBACK TRANSACTION ELSE THROW END CATCH END Deadlock (for disk-based tables) Hekaton-specific error codes

29 CREATE PROCEDURE type2,... AS BEGIN INT = 10 WHILE > 0) BEGIN BEGIN TRY = 0 END TRY BEGIN CATCH -= 1 IF > 0 AND error_number() in (41302, 41305, 41325, 41301, 1205)) IF ROLLBACK TRANSACTION ELSE THROW END CATCH END

30

31 CREATE TABLE t1 ( c1 INT NOT NULL IDENTITY..., c2 INT, c3 DATE) CREATE TABLE t1 ( c1 INT NOT NULL..., c2 INT, c3 DATE) WITH (MEMORY_OPTIMIZED=ON) Before migration:After migration: CREATE PROC INT, c3 DATE AS BEGIN INSERT INTO t1 END CREATE SEQUENCE usq_t1 AS INT START WITH 1 INCREMENT BY 1 CREATE PROC INT, c3 DATE AS BEGIN INT = NEXT VALUE FOR usq_t1 INSERT INTO END

32

33

34 Windows Azure

35

36

37

38


Download ppt "Project “Hekaton” adds in-memory technology to boost performance of OLTP workloads in SQL Server."

Similar presentations


Ads by Google