Perhaps you have heard the term “In-Memory” but not sure what it means. If you are a SQL Server Professional then you will want to know. Even if you are new to SQL Server, you will want to learn more about this topic. Come learn the basics of how In-Memory OLTP technology in SQL Server 2016 and Azure SQL Database can boost your OLTP application by 30X. We will compare how In-Memory OTLP works vs “normal” disk-based tables. We will discuss what is required to migrate your existing data into memory optimized tables or how to build a new set of data and applications to take advantage of this technology. This presentation will cover the fundamentals of what, how, and why this technology is something every SQL Server Professional should know
8. “Feels” like normal disk-based tables
but in memory
Internally completely different
Hash or non-clustered index choices
(at least one required)
9.
10.
11. Create a Memory
Optimized
FILEGROUP
Decide on an
index strategy
Create a
Memory-
Optimized Table
Create a natively
compiled stored
procedure
Start running
transactions
Tune and
manage
12. • Estimating Table, Index, Versioning, and Growth. Read here
Do I have enough
Memory?
• Hash = unique row lookup
• Non-clustered = range lookups (also called range index)
Hash or Non-clustered
index?
• SCHEMA_ONLY = Does not persist server restarts; No I/O (even log)
• SCHEMA_AND_DATA = Persists server restartsDurability
• Ultimate speed vs some limits
• Limited diagnostics by default
Use Natively Compiled
Stored Procedures?
• Transaction Log - Transactions only as fast as commit speed
• FILEGROUP – One or multiple folders across drives for faster startupPhysical File Placement
NVDIMM
13. Transaction Performance Analysis Report
Memory Optimization Advisor
Native Compilation Advisor
Analyze based
on DMVs
Recommend
changes
Find
incompatibilities
Migrate schema,
data, and procs
14.
15.
16. • Locks the table
• Maintain indexes
• Used to maintain bucketcount for hash indexes
• Natively Compled Procedures are SCHEMABOUND
ALTER memory
optimized tables
• Auto Update statistics supported (requires db compat level = 130)
• Natively Compiled Stored Procedures not recompiled on auto status update
Maintaining
Statistics
• Need to reduce space? Delete rows or drop tables
• Bind to your own RG resource pool with sp_xtp_bind_db_resource_pool
Managing
Memory Usage
17. Always On Availability Groups
HTAP applications
Azure SQL Database
Cross container transactions
Table variables
here
BACKUP/RESTORE
18.
19. Immutable
• Rows never change: UPDATE =
DELETE + INSERT
Versions
• UPDATE and DELETE create
versions
• Timestamps in rows for visibility
and transactions correctness
Optimistic
• Assume no conflicts
• Snapshots + conflict detection
• Guarantee correct transaction
isolation at commit
NOT in
tempdb
Pessimistic
= locks
Errors may occur
20. Release latches and locks
Update index pages ( more locks and latch )
Modify page
Latch page
Obtain locks
INSERT LOG record
In-Memory OLTP INSERT
Maintain index in
memory
Insert ROW into
memory
COMMIT Transaction = Log
Record and Flush
COMMIT Transaction = Insert
HK Log Record and Flush
Page Split
Sys Tran =
Log Flush
Spinlocks
No index
logging
SCHEMA_ONLY
no logging
No latch
No spinlock
21. Log truncation eligible
at CHECKPOINT event
No WAL protocol
Typically 128Mb
but can be 1Gb
Typically 8Mb but
can be 128Mb
Read details from
database Boot Page
(DBINFO)
Load ROOT file for
system tables and
file metadata
Load ACTIVE DATA
files filtered by
DELTA streamed in
parallel
Redo COMMITED
transactions greater
than last
CHECKPOINT LSN
22.
23. • SQL Server In-Memory OLTP Internals for SQL Server 2016
• In-Memory OLTP Videos: What it is and When/How to use it
• Explore In-Memory OLTP architectures and customer case studies
• In-Memory OLTP in Azure SQL Database Blog
• In-Memory OLTP (In-Memory Optimization) docs
http://aka.ms/bobwardms
Notas do Editor
Use the instructions in readme.md in demo1_just_show_us
Notice that log records are not even created until COMMIT.