SQL Track: In Memory OLTP in SQL Server
-
Upload
itproceed -
Category
Technology
-
view
218 -
download
4
description
Transcript of SQL Track: In Memory OLTP in SQL Server
![Page 1: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/1.jpg)
In Memory OLTP
SQL server 2014 Hekaton Engine
Frederik Bogaerts
![Page 2: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/2.jpg)
Give me more
![Page 3: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/3.jpg)
NSLOOKUP 127.0.0.0
![Page 4: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/4.jpg)
Hekaton in a nutshell
Please ExplainWhy Demo
![Page 5: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/5.jpg)
So long …
![Page 6: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/6.jpg)
Hekaton – In Memory OLTPHash
Indexes
Memory Optimiz
ed Tables
Range Indexe
s
Latch-free
![Page 7: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/7.jpg)
Hekaton Engine
Source: Microsoft.com
![Page 8: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/8.jpg)
Prepare your databaseCreate Database Add memory optimized filegroup Add file to filegroup
![Page 9: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/9.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/10.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/11.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/12.jpg)
Indexes
Buckets
Point Lookups
HashRange Scanning
BW-Tree
Non Clustered
![Page 13: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/13.jpg)
Hash Indexes
Source: Microsoft.com
![Page 14: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/14.jpg)
Range Indexes
Source: Microsoft.com
![Page 15: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/15.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/16.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/17.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/18.jpg)
Garbage Collection
Multi Versioning Stale Rows Scans slow Bloathing memory
![Page 19: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/19.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/20.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/21.jpg)
Going For Gold
![Page 22: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/22.jpg)
Please ExplainWhy Demo
![Page 23: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/23.jpg)
![Page 24: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/24.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/25.jpg)
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](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/26.jpg)
Thank You!
![Page 27: SQL Track: In Memory OLTP in SQL Server](https://reader035.fdocuments.net/reader035/viewer/2022062405/556424a0d8b42a2a0a8b589e/html5/thumbnails/27.jpg)
Belgium’s biggest IT PRO Conference