Presentation is loading. Please wait.

Presentation is loading. Please wait.

IN-MEMORY OLTP By Manohar Punna SQL Server Geeks – Regional Mentor, Hyderabad Blogger, Speaker.

Similar presentations


Presentation on theme: "IN-MEMORY OLTP By Manohar Punna SQL Server Geeks – Regional Mentor, Hyderabad Blogger, Speaker."— Presentation transcript:

1 Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks IN-MEMORY OLTP By Manohar Punna SQL Server Geeks – Regional Mentor, Hyderabad Blogger, Speaker Sr. DBA at S&P Capital IQ (McGraw Hill Financials)

2 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

3 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

4 Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks Memory is getting cheaper Efficient processing of instructions  With Native compiled SP execution is just a DLL entry point  Aggressively optimized at compile time Scale-Up Issues  No Paging  Lock free structure  Optimistic concurrency with full ACID support Why In-Memory

5 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.

6 Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks Memory Optimized Tables Memory Buffer Pool Asynchronous data Sync SQL DB Engine Process Hekaton DB Engine Recovery R1R3 R2

7 Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks Lets LEARN this by a Demo How Stuff Works – Create, Insert, Read

8 Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks How Stuff Works – Row Format Row HeaderPayload (data in columns) Begin TsEnd TsStmnt IDInd Link Count 8 bytes 4 bytes2 bytes8b*(IndLinkCount – 1) Begin Ts and End Ts determine the validity of the record Row size limited to 8060 bytes Row linking leads to collisions. Can be avoided by providing more hash buckets. Off-Row storage types are not allowed (XML, BLOB, Spatial)

9 Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks How Stuff Works – Garbage Collection Row Versions are created for Update, Delete and Aborted transactions GC is non blocking, cooperative and efficient  Dedicated GC background thread  Active Transactions work cooperatively to perform GC  Based on oldest Active Transaction Hint 1002001FN1MN1LN1 300∞1FN1MN1LN1 501001FN1MN1LN1 200∞1FN1MN1LN1 Hash Index Tran 5 = 210 Oldest Active Hint = 175

10 Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks How Stuff Works – Data Storage Data storage is two types – Durable and Non-Durable Storage is a dedicated filestream in a Memory Optimized filegroup The data access is sequential Two types of files as pairs – Data and Delta Data 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

11 Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks How Stuff Works – Data Storage (2) TS(Ins)TableIDRowIDRow Payload TS(Ins)TS(Del)RowID Data File Delta File Checkpoint File Pair 0 100

12 Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks How Stuff Works – Transaction Logging The log records are logical Physical structure modifications are not logged Index specific or Index maintenance operations not logged Undo information is not logged Transaction are logged only when the commit occurs SQL Log HeaderOpaque Hekaton specific log content

13 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

14 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

15 Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks

16 www.FaceBook.com/SQLServerGeeks Be a member – www.SQLServerGeeks.comwww.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…

17 Twitter: @SQLServerGeeks www.FaceBook.com/SQLServerGeeks Thank you for suggestions, please email at admin@SQLServerGeeks.comadmin@SQLServerGeeks.com


Download ppt "IN-MEMORY OLTP By Manohar Punna SQL Server Geeks – Regional Mentor, Hyderabad Blogger, Speaker."

Similar presentations


Ads by Google