Top 5 Things You Didn't Know About InMemory...
Transcript of Top 5 Things You Didn't Know About InMemory...
Top 5 Things You Didn't Know About InMemory OLTP
Vinod Kumar M
@vinodk_sql
http://blogs.ExtremeExperts.com
Your
company
logo here
Myths about In-Memory OLTP
• SQL Server In-Memory OLTP is a recent
response to competitors’ offerings
• In-Memory OLTP is like DBCC PINTABLE
• In-Memory Databases are new separate products
• You can use In-Memory OLTP in an existing SQL
Server app with NO changes whatsoever
• Since tables are in memory, the data is not
Durable or Highly Available – I will lose it after
server crash
What is In-Memory OLTP?• SQL Server 2014 adds in-memory technology to boost performance of OLTP workloads
Create Table DDLCREATE TABLE [Customer](
[CustomerID] INT NOT NULL
PRIMARY KEY NONCLUSTERED HASH WITH (BUCKET_COUNT = 1000000),
[Name] NVARCHAR(250) NOT NULL
INDEX [IName] HASH WITH (BUCKET_COUNT = 1000000),
[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
Memory Optimized Table Creation
Create Table DDL
Code generation and compilation
Table DLL produced
Table DLL loaded
UNDERSTANDING HASH INDEXES
Hash Indexes
4567
0123
Array of
8-byte
Memory
pointers
Hash index with (bucket_count=8): Hash function f:• Maps values to buckets
• Built into the systemHash mapping:
f(Lakhani)
f(Vinod)f(Pinal)
f(MP)
f(CHENNAI)
Hash
Collisionsf(KAR)
Memory Optimized Tables and Indexes
50, ∞ Pinal BLR
Timestamps NameChain ptrs City
Hash index
on CityHash index
on Name
90, ∞ Vinod Chennai
f(Pinal)
f(Vinod)
f(BLR)
f(Chennai)
Memory Optimized Tables and Indexes
50, ∞ Pinal BLR
Timestamps NameChain ptrs City
Hash index
on CityHash index
on Name
T100: INSERT (Balu, BLR)
100, ∞ Balu BLR
90, ∞ Vinod Chennai
f(Balu) f(BLR)
90, 150 Vinod Chennai
Memory Optimized Tables and Indexes
50, ∞ Pinal BLR
Timestamps NameChain ptrs City
Hash index
on CityHash index
on Name
T150: DELETE (Vinod, Chennai)
100, ∞ Balu BLR
Memory Optimized Tables and Indexes
90, 150 Vinod Chennai
50, ∞ Pinal BLR
Timestamps NameChain ptrs City
Hash index
on CityHash index
on Name
T200: UPDATE
(Balu, BLR) to
(Balu, Chennai)
100, ∞ Balu BLR
200, ∞ Balu Chennai
100, 200
f(Chennai)
f(Balu)
Memory Optimized Tables and Indexes
90, 150 Vinod Chennai
50, ∞ Pinal BLR
Timestamps NameChain ptrs City
Hash index
on CityHash index
on Name
T250: Garbage collection
100, 200 Balu BLR
200, ∞ Balu Chennai
f(Balu)
f(Pinal)
f(Chennnai)
f(BLR)
HOW INMEMORY PROCEDURES ARE CREATED !!!
Procedure Creation
CREATE PROC DDL
Query optimization
Code generation and compilation
Procedure DLL produced
Procedure DLL loaded
Backup for Memory-Optimized Tables
• Integrated with SQL Database Backup
– Memory-Optimized file group is backed up
as part SQL database backup
• Existing backup scripts work with minimal or
no changes
• Transaction log backup includes memory-
optimized log records transparently
• Not supported
– Differential backup
QUESTION