twitter: @sqlservergeeks in-memory oltp by manohar punna sql server geeks – regional mentor,...
TRANSCRIPT
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
IN-MEMORY OLTPBy
Manohar PunnaSQL Server Geeks – Regional Mentor, Hyderabad
Blogger, SpeakerSr. DBA at S&P Capital IQ (McGraw Hill Financials)
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
Speaker Details
Manohar Punna (Regional Mentor, Hyderabad)
5+ Years of experience as Core SQL DBA
Blogger and Speaker at SQL Server Geeks
Worked in various business models supporting databases including Microsoft GTSC
MCITP Certified Currently working at McGraw Hill
Financials as a Sr SQL DBA in Escalation team
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
Agenda
Why In-Memory?
Disk Based Tables vs. Memory Optimized Tables
How Stuff Works
Demo – Create, Insert, Read Row Format Garbage Collection Data Storage Transaction Logging
Considerations
Summary
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
Memory is getting cheaperEfficient processing of instructionsWith Native compiled SP execution is just a DLL entry
pointAggressively optimized at compile time
Scale-Up IssuesNo PagingLock free structureOptimistic concurrency with full ACID support
Why In-Memory
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
Disk Based Tables
Memory
Buffer Pool
Physical Reads
SQL DB Engine Process
Checkpoint Lazy Writer
Consider a scenario with NCI scan followed by a key lookup.
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
Memory Optimized Tables
Memory
Buffer Pool
Asynchronous data Sync
SQL DB Engine Process
Hekaton DB Engine
Recovery
R1 R3
R2
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
Lets LEARN
this by a Demo
How Stuff Works – Create, Insert, Read
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
How Stuff Works – Row Format
Row Header Payload (data in columns)
Begin Ts End Ts Stmnt ID Ind Link Count8 bytes 8 bytes 4 bytes 2 bytes 8b*(IndLinkCount – 1)
Begin Ts and End Ts determine the validity of the recordRow size limited to 8060 bytesRow linking leads to collisions. Can be avoided by providing more hash buckets.Off-Row storage types are not allowed (XML, BLOB, Spatial)
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
How Stuff Works – Garbage Collection
Row Versions are created for Update, Delete and Aborted transactionsGC is non blocking, cooperative and efficient
Dedicated GC background thread Active Transactions work cooperatively to perform GC Based on oldest Active Transaction Hint
100 200 1 FN1 MN1 LN1
300 ∞ 1 FN1 MN1 LN1
50 100 1 FN1 MN1 LN1
200 ∞ 1 FN1 MN1 LN1
Hash Index Tran 5 = 210Oldest Active Hint = 175
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
How Stuff Works – Data Storage
Data storage is two types – Durable and Non-DurableStorage is a dedicated filestream in a Memory Optimized filegroupThe data access is sequentialTwo types of files as pairs – Data and DeltaData Files
128 MB file size with 256 kb pages Stores only Inserted rows
Delta Files Grows by 4kb pages over time Contains only IDs of deleted rows
Data files are merged overtime to reuse the space. Manually - sys.sp_merge_xtp_checkpoint_files
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
How Stuff Works – Data Storage (2)
TS(Ins) TableID RowID Row Payload
TS(Ins) TS(Del) RowID
Data File
Delta File
Checkpoint File Pair
0
100
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
How Stuff Works – Transaction Logging
The log records are logicalPhysical structure modifications are not loggedIndex specific or Index maintenance operations not loggedUndo information is not loggedTransaction are logged only when the commit occurs
SQL Log Header Opaque Hekaton specific log content
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
Considerations
Space needed in Memory Table data - 2X the data size Index data - Bucket_Count x Pointer_Size (8 bytes)
Space needed on Disk Data 2X-3X the table size Log - Less than disk based tables. If latency is important use SSD
Backups Differential is not supported Piecemeal Restore should include Hekaton File Group restored with
Primary CTP1 includes Data and Delta files with t-log backups
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
Summary
Covered creation of In-Memory table
Advantages of In-Memory table over disk-based table
Storage structure of Hekaton
Logging with Memory Optimized tables
What next Native Compiled Stored Procedures Deep dive with more demos
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
Q & A
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
www.FaceBook.com/SQLServerGeeks
Be a member – www.SQLServerGeeks.com
@SQLServerGeeks
Talk about your experience Post photos Blog, Tweet (#SQLServerGeeks) Post your experience on Forums
Why do all this? “We want to make the community bigger & larger and
we need your support”
Spread the word…
Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks
Thank you
for suggestions, please email at [email protected]