Presentation is loading. Please wait.

Presentation is loading. Please wait.

9/11/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.

Similar presentations


Presentation on theme: "9/11/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks."— Presentation transcript:

1 9/11/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

2 In-Memory OLTP for DB Developers
9/11/2018 DBI-B386 In-Memory OLTP for DB Developers Jos de Bruijn © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

3 Session Objectives And Takeaways
Tech Ready 15 9/11/2018 Session Objectives And Takeaways Session Objective(s): Assess if an application is a good fit for In-Memory OLTP Migrate applications to In-Memory OLTP Key Takeaways: If you know SQL Server, you know In-Memory OLTP In-Memory OLTP uses new table and index structures, and a new transaction processing model © 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.

4 TechReady 16 9/11/2018 In-Memory OLTP Recap SQL Server 2014 adds in-memory technology to boost performance of OLTP workloads Memory optimized table and index structures Native compilation of business logic in stored procedures Latch- and lock-free data structures Fully integrated into SQL Server © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

5 In-Memory OLTP for DB Developers
Memory optimized tables and indexes Accessing memory-optimized tables Transactions on memory optimized tables

6 Memory optimized tables and indexes
9/11/2018 4:16 PM Memory optimized tables and indexes © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

7 Create Table DDL CREATE TABLE [Customer]( [CustomerID] INT NOT NULL
Hash Index BUCKET_COUNT 1-2X nr of unique index key values Oversizing is OK CREATE TABLE [Customer]( [CustomerID] INT NOT NULL PRIMARY KEY NONCLUSTERED HASH WITH (BUCKET_COUNT = ), [Name] NVARCHAR(250) NOT NULL, [CustomerSince] DATETIME2 NULL INDEX [ICustomerSince] NONCLUSTERED ) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA); Indexes are specified inline NONCLUSTERED indexes are supported This table is memory optimized This table is durable Non-durable tables: DURABILITY=SCHEMA_ONLY

8 Create Table Type CREATE TYPE [Sales].[SalesOrderDetailType_inmem] AS TABLE ( [OrderQty] [smallint] NOT NULL, [ProductID] [int] NOT NULL, [SpecialOfferID] [int] NOT NULL, [LocalID] [int] NOT NULL, INDEX [IX_ProductID] HASH ([ProductID]) WITH ( BUCKET_COUNT = 8), INDEX [IX_SpecialOfferID] HASH ([SpecialOfferID]) WITH ( BUCKET_COUNT = 8) ) WITH ( MEMORY_OPTIMIZED = ON )

9 Memory Optimized Table Creation
CREATE TABLE DDL Code generation and compilation Table DLL produced Table DLL loaded

10 Memory-Optimized Indexes
Exist only in memory Rebuilt on database startup Do not contain data rows Indexes contain memory pointers to the data rows No duplication of data All indexes are covering Nonclustered Indexes No need to specify any options Optimized for range lookups and ordered scans Support search on leading columns of the index key Support point-lookups, but hash indexes are much faster Hash Indexes Need to specify bucket_count – usually 1-2X the number of unique index keys Optimized for point-lookups Cannot be used for search on subset of the index key Cannot be used for range lookups (search on inequality predicate) or ordered scans (for ORDER BY)

11 Index Considerations Choosing HASH vs. NONCLUSTERED
TechReady 18 9/11/2018 Index Considerations Choosing HASH vs. NONCLUSTERED NONCLUSTERED is the safe baseline, as it supports all operations Use HASH to optimize inserts and point lookups – inequality seeks and ordered scans not supported You can have both indexes on the same columns Hash Index Bucket Count Choose at least as many buckets as unique index key values – over-sizing is usually OK Automatically rounds up to the next power of 2 In case of many duplicates use a NONCLUSTERED index Hash Index Key Columns Does not support seek on subset of key columns Index key must include exactly the columns you are searching on Nonclustered Index Key: Choose direction (ASC/DESC) that conforms to ORDER BY requirement © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

12 Demo Memory-optimized Indexes (script in the notes) TechReady 18
9/11/2018 Demo Memory-optimized Indexes (script in the notes) -- ============ start of tables/index demo USE master GO SET NOCOUNT ON if exists (select * from sys.databases where name='ContosoOLTP') drop database ContosoOLTP go CREATE DATABASE ContosoOLTP ----- Enable database for memory optimized tables -- add memory_optimized_data filegroup ALTER DATABASE ContosoOLTP ADD FILEGROUP contoso_mod CONTAINS MEMORY_OPTIMIZED_DATA -- add container to the filegroup ADD FILE (NAME='contoso_mod', FILENAME='c:\data\contoso_mod') TO FILEGROUP contoso_mod -- set MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT to automatically map READ COMMITTED to SNAPSHOT SET MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT=ON USE ContosoOLTP IF EXISTS (SELECT * FROM sys.objects WHERE name='InsertOrder') DROP PROC dbo.InsertOrder IF EXISTS (SELECT * FROM sys.objects WHERE name='InsertOrders') DROP PROC dbo.InsertOrders IF EXISTS (SELECT * FROM sys.objects WHERE name='SalesOrders') DROP TABLE dbo.SalesOrders CREATE TABLE dbo.SalesOrders ( order_id INT NOT NULL, order_date DATETIME2 NOT NULL, order_status TINYINT NOT NULL, INDEX IX_date NONCLUSTERED (order_date), CONSTRAINT PK_SalesOrders PRIMARY KEY NONCLUSTERED HASH (order_id) WITH (BUCKET_COUNT = ) ) WITH (MEMORY_OPTIMIZED = ON) SELECT name, object_id, is_memory_optimized, durability, durability_desc FROM sys.tables WHERE type='U' select db_id() -- show generated files -- insert sample data INSERT dbo.SalesOrders VALUES (1, ' ', 1) INSERT dbo.SalesOrders VALUES (2, ' ', 1) INSERT dbo.SalesOrders VALUES (3, ' ', 1) INSERT dbo.SalesOrders VALUES (4, ' ', 1) INSERT dbo.SalesOrders VALUES (5, ' ', 1) EXEC sp_updatestats -- point lookup using hash SELECT order_date, order_status FROM dbo.SalesOrders WHERE order_id=2 SET SHOWPLAN_XML ON SET SHOWPLAN_XML OFF -- attempt range scan [not supported in hash index] WHERE order_id>2 -- sort [not supported in hash index] ORDER BY order_id -- point lookup using nonclustered SELECT order_id, order_status WHERE order_date=' ' -- range scan WHERE order_date>=' ' -- sort SELECT order_date, order_id, order_status ORDER BY order_date -- clean up DELETE FROM dbo.SalesOrders © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

13 Accessing memory optimized tables
9/11/2018 4:16 PM Accessing memory optimized tables © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

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

15 Procedure Creation CREATE PROC DDL Query optimization
Code generation and compilation Procedure DLL produced Procedure DLL loaded

16 Accessing Memory Optimized Tables
TechReady 16 9/11/2018 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 Access both memory- and disk-based tables Less performant Virtually full T-SQL surface When to use Ad hoc queries Reporting-style queries Surface area not available in native © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

17 Demo Accessing Memory Optimized Tables (script in the notes)
9/11/2018 4:16 PM Demo Accessing Memory Optimized Tables (script in the notes) -- ============ start of table access demo USE ContosoOLTP GO SET NOCOUNT ON BEGIN TRAN DECLARE @id int = 1, @status tinyint = 1 <= BEGIN INSERT dbo.SalesOrders VALUES += 1 END COMMIT SELECT TOP 100 * FROM dbo.SalesOrders SELECT TOP 100 * FROM dbo.SalesOrders ORDER BY order_id DELETE FROM dbo.SalesOrders CREATE PROCEDURE dbo.InsertOrders WITH NATIVE_COMPILATION, SCHEMABINDING, EXECUTE AS OWNER AS BEGIN ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N'us_english') set statistics time on EXEC dbo.InsertOrders set statistics time off CREATE PROCEDURE tinyint INSERT @order_date datetime, = sysdatetime() @status -- clean up -- ============ end of table access demo © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

18 Transactions on memory optimized tables
9/11/2018 4:16 PM Transactions on memory optimized tables © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

19 In-Memory OLTP Concurrency Control
TechReady 16 9/11/2018 In-Memory OLTP Concurrency Control Multi-version data store Snapshot-based transaction isolation No TempDB Multi-version No locks, no latches, minimal context switches No blocking Conflict detection to ensure isolation No deadlocks Optimistic © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

20 Supported Isolation Levels
9/11/2018 4:16 PM Supported Isolation Levels SNAPSHOT Reads are consistent as of start of the transaction Writes are always consistent DB option MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT maps READ COMMITTED to SNAPSHOT, limiting the app changes needed REPEATABLE READ Read operations yield same row versions if repeated at commit time SERIALIZABLE Transaction is executed as if there are no concurrent transactions – all actions happen at a single serialization point (commit time) No phantom rows © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

21 Example: Write conflict
Time Transaction T1 (SNAPSHOT) Transaction T2 (SNAPSHOT) 1 BEGIN 2 3 UPDATE t SET c1=‘value2’ WHERE c2=123 4 UPDATE t SET c1=‘value1’ WHERE c2=123 (write conflict) First writer wins

22 Guidelines for usage Use Database Option MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT for easier migration Declare isolation level – no locking hints Use retry logic to handle conflicts and validation failures Avoid using long-running transactions

23 Demo Transaction Isolation (script in the notes) 9/11/2018 4:16 PM
-- ============ start of transactions demo [first connection] -- the script for the second connection is below IF EXISTS (SELECT * FROM sys.objects WHERE name='SalesOrders_disk') DROP TABLE dbo.SalesOrders_disk go CREATE TABLE dbo.SalesOrders_disk ( order_id INT NOT NULL, order_date DATETIME NOT NULL, order_status TINYINT NOT NULL, INDEX IX_date CONSTRAINT PK_SalesOrders_disk PRIMARY KEY (order_id) ) GO INSERT dbo.SalesOrders VALUES (1, sysdatetime(), 1) INSERT dbo.SalesOrders VALUES (2, sysdatetime(), 2) INSERT dbo.SalesOrders_disk VALUES (1, sysdatetime(), 1) INSERT dbo.SalesOrders_disk VALUES (2, sysdatetime(), 2) -- update disk-based table --step 1 BEGIN TRAN UPDATE dbo.SalesOrders_disk SET order_status=2 WHERE order_id=1 --step 3 COMMIT -- update memory-optimized table UPDATE dbo.SalesOrders --step 4 --step 5 SELECT * FROM dbo.SalesOrders WHERE order_id=1 -- disk-based REPEATABLEREAD deadlock -- TxA -- step 1 SELECT * FROM dbo.SalesOrders_disk WITH (REPEATABLEREAD) -- step 3 UPDATE dbo.SalesOrders_disk WITH (REPEATABLEREAD) SET order_status=3 WHERE order_id=2 -- memory-optimized REPEATABLEREAD validation failure SELECT * FROM dbo.SalesOrders WITH (REPEATABLEREAD) UPDATE dbo.SalesOrders WITH (REPEATABLEREAD) -- step 5 -- disk-based READCOMMITTED deadlock UPDATE dbo.SalesOrders_disk WITH (READCOMMITTED) SET order_status=4 SELECT * FROM dbo.SalesOrders_disk WITH (READCOMMITTED) -- memory-optimized SNAPSHOT no failure UPDATE dbo.SalesOrders WITH (SNAPSHOT) SELECT * FROM dbo.SalesOrders WITH (SNAPSHOT) -- ======================================================================= ================================================== -- ============ end of transactions demo [first connection] -- ============ start of transactions demo [second connection] USE ContosoOLTP --step 2 SELECT * FROM dbo.SalesOrders_disk WHERE order_id=1 UPDATE dbo.SalesOrders SET order_status=3 WHERE order_id=1 -- REPEATABLEREAD deadlock -- TxB -- step 2 -- step 4 -- step 6 © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

24 Limitations in SQL Server 2014
Tables Triggers: no DDL/DML triggers Data types: no LOBs, no XML and no CLR data types Constraints: no FOREIGN KEY and no CHECK constraints No schema changes (ALTER TABLE) – need to drop/recreate table No add/remove index – need to drop/recreate table Natively Compiled Stored Procedures No OUTER JOIN, no DISTINCT no OR, no subqueries, no CASE Limited built-in functions [core math, date/time, and string functions are supported]

25 Recap Memory optimized tables and indexes
Are natively compiled on create New hash indexes Considerations for choosing nonclustered vs. hash Accessing memory optimized tables Natively compiled stored procedures – best performance, but T-SQL limitations Interpreted T-SQL access – full T-SQL surface area, and joins with disk-based tables Transaction semantics Multi-versioned, snapshot-based isolation Optimistic: no locking – conflict detection © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

26 In Review: Session Objectives And Takeaways
Tech Ready 15 9/11/2018 In Review: Session Objectives And Takeaways Session Objective(s): Assess if an application is a good fit for In-Memory OLTP Migrate applications to In-Memory OLTP Key Takeaways: If you know SQL Server, you know In-Memory OLTP In-Memory OLTP uses new table and index structures, and a new transaction processing model © 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.

27 Related content at TechEd
9/11/2018 Related content at TechEd Breakout Sessions (in logical order) DBI-B287 - Microsoft SQL Server 2014: In-Memory OLTP Overview DBI-B386 - Microsoft SQL Server 2014: In-Memory OLTP for Database Developers DBI-B385 - Microsoft SQL Server 2014: In-Memory OLTP for Database Administrators DBI-B384 - Microsoft SQL Server 2014: In-Memory OLTP End-to-End: Preparing for Migration DBI-B315 - Microsoft SQL Server 2014: In-Memory OLTP: Memory/Storage Monitoring and Troubleshooting DBI-B488 - Microsoft SQL Server 2014: In-Memory OLTP Performance Troubleshooting DBI-B313 - Microsoft SQL Server 2014: In-Memory OLTP Customer Deployments and Lessons Learned © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

28 Related content online
Overview of all In-Memory OLTP posts on the SQL Server blog In-Memory OLTP Sample Database and Workload (based on AdventureWorks) Books Online documentation for In-Memory OLTP Indexes: Getting started with In-Memory OLTP Guidelines for natively compiled stored procedures: Analysis and Migration tools Transaction isolation with In-Memory OLTP Choosing isolation level: Implementing retry logic: Limitations and workarounds

29 Visit the Developer Platform & Tools Booth
Having a friend buy your coffee? Yea, it’s kind of like that. MSDN Subscribers get up to $150/mo in Azure credits. Stop by the Developer Platform and Tools booth and visit the MSDN Subscriptions station to activate your benefits and receive a gift! 3 Steps to New Gear! With Application Insights Create a Visual Studio Online account Install Application Insights Tools for Visual Studio Online Come to our booth for a t-shirt and a chance to win! VSIP QR Tag Contests Visit our booth to join the hunt for cool prizes!

30 Resources Microsoft Engineering Stories
Development tools & services for teams of all sizes How Microsoft Builds Software Visual Studio Industry Partner Program Visual Studio | Integrate Meet Our New Visual Studio Online Partners or Join Now. Create Your Own Dev Environment

31 Resources Learning TechNet msdn http://channel9.msdn.com/Events/TechEd
9/11/2018 Resources Sessions on Demand Learning Microsoft Certification & Training Resources TechNet Resources for IT Professionals msdn Resources for Developers © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

32 Complete an evaluation and enter to win!
9/11/2018 Complete an evaluation and enter to win! © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

33 Evaluate this session Scan this QR code to evaluate this session.
9/11/2018 Evaluate this session Scan this QR code to evaluate this session. © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

34 9/11/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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. © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

35 Appendix

36 Retry Logic for Transaction Failures
Failures causing transaction abort Write conflicts, validation failures Aborted transactions need to be retried Solution: implement retry logic Server-side retry avoids changes to client apps

37 Retry Logic for Transaction Failures
9/11/2018 4:16 PM Retry Logic for Transaction Failures You will now see how retry logic can be implemented on the server without requiring changes to the client application © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

38 Retry Logic for Transaction Failures
9/11/2018 4:16 PM Retry Logic for Transaction Failures CREATE PROCEDURE type2, ... AS BEGIN END You create a wrapper stored procedure with the same name your application has been using. After migration, the client application will call this stored procedure © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

39 Retry Logic for Transaction Failures
9/11/2018 4:16 PM Retry Logic for Transaction Failures CREATE PROCEDURE type2, ... AS BEGIN INT = 10 WHILE > 0) END You will use a WHILE loop for retries, and limit the number of retries. The number ‘10’ here is an example © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

40 Retry Logic for Transaction Failures
9/11/2018 4:16 PM Retry Logic for Transaction Failures CREATE PROCEDURE type2, ... AS BEGIN INT = 10 WHILE > 0) BEGIN TRY = 0 END TRY BEGIN CATCH -= 1 END CATCH END You use a try/catch block to catch and handle the failures, keeping track of the retry count © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

41 Retry Logic for Transaction Failures
9/11/2018 4:16 PM Retry Logic for Transaction Failures CREATE PROCEDURE type2, ... AS BEGIN INT = 10 WHILE > 0) 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 Hekaton-specific error codes Deadlock (for disk-based tables) If any of these error conditions occur, you will rollback the transaction, and the WHILE loop will ensure the retry happens This gives you the retry framework. © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.

42 Retry Logic for Transaction Failures
9/11/2018 4:16 PM Retry Logic for Transaction Failures CREATE PROCEDURE type2, ... AS BEGIN INT = 10 WHILE > 0) 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 Finally, you will add the call to your natively compiled stored procedure, or, alternatively, add an explicit transaction that accesses memory optimized tables through interpreted T-SQL © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, 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.


Download ppt "9/11/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks."

Similar presentations


Ads by Google