Hekaton: SQL Server s Memory-Optimized OLTP Engine



Similar documents
Hekaton: SQL Server s Memory-Optimized OLTP Engine

SQL Server 2014 In-Memory Tables (Extreme Transaction Processing)

SQL Server In-Memory OLTP Internals Overview for CTP2

W I S E. SQL Server 2008/2008 R2 Advanced DBA Performance & WISE LTD.

SQL Server Transaction Log from A to Z

David Dye. Extract, Transform, Load

Improve Business Productivity and User Experience with a SanDisk Powered SQL Server 2014 In-Memory OLTP Database

WITH A FUSION POWERED SQL SERVER 2014 IN-MEMORY OLTP DATABASE

SQL Server 2014 New Features/In- Memory Store. Juergen Thomas Microsoft Corporation

Trekking Through Siberia: Managing Cold Data in a Memory-Optimized Database

Optimizing Performance. Training Division New Delhi

Compilation in the Microsoft SQL Server Hekaton Engine

Configuring Apache Derby for Performance and Durability Olav Sandstå

SQL Server 2016 New Features!

Developing Microsoft SQL Server Databases 20464C; 5 Days

Configuring Apache Derby for Performance and Durability Olav Sandstå

SAP HANA - Main Memory Technology: A Challenge for Development of Business Applications. Jürgen Primsch, SAP AG July 2011

20464C: Developing Microsoft SQL Server Databases

Performance Counters. Microsoft SQL. Technical Data Sheet. Overview:

Course 20464: Developing Microsoft SQL Server Databases

Developing Microsoft SQL Server Databases MOC 20464

The Database is Slow

MS SQL Server 2014 New Features and Database Administration

Inside Microsoft SQL Server 2005: The Storage Engine

MS SQL Performance (Tuning) Best Practices:

How To Improve Performance In A Database

BOOST YOUR SQL PERFORMANCE BY USING THE NEW

Developing Microsoft SQL Server Databases

Java DB Performance. Olav Sandstå Sun Microsystems, Trondheim, Norway Submission ID: 860

SQL Server 2012 Optimization, Performance Tuning and Troubleshooting

Developing Microsoft SQL Server Databases (20464) H8N64S

Data Management in the Cloud

Would-be system and database administrators. PREREQUISITES: At least 6 months experience with a Windows operating system.

Boost SQL Server Performance Buffer Pool Extensions & Delayed Durability

Understanding SQL Server Execution Plans. Klaus Aschenbrenner Independent SQL Server Consultant SQLpassion.at

Outline. MCSE: Data Platform. Course Content. Course 10776C: MCSA: Developing Microsoft SQL Server 2012 Databases 5 Days

Outline. Failure Types

Course 20464C: Developing Microsoft SQL Server Databases

Ontrack PowerControls V8.1 for SQL ReadMe

Course 55144: SQL Server 2014 Performance Tuning and Optimization

"Charting the Course... MOC AC SQL Server 2014 Performance Tuning and Optimization. Course Summary

Course 55144B: SQL Server 2014 Performance Tuning and Optimization

Raima Database Manager Version 14.0 In-memory Database Engine

Microsoft SQL Database Administrator Certification

COS 318: Operating Systems

Backup and Restore Back to Basics with SQL LiteSpeed

IN-MEMORY DATABASE SYSTEMS. Prof. Dr. Uta Störl Big Data Technologies: In-Memory DBMS - SoSe

Real-Time Analytical Processing with SQL Server

High-Performance Concurrency Control Mechanisms for Main-Memory Databases

MS-40074: Microsoft SQL Server 2014 for Oracle DBAs

Oracle Architecture, Concepts & Facilities

FHE DEFINITIVE GUIDE. ^phihri^^lv JEFFREY GARBUS. Joe Celko. Alvin Chang. PLAMEN ratchev JONES & BARTLETT LEARN IN G. y ti rvrrtuttnrr i t i r

SQL Server Encryption Overview. September 2, 2015

SQL Server 2012 Query. Performance Tuning. Grant Fritchey. Apress*

DataBlitz Main Memory DataBase System

StruxureWare Power Monitoring Database Upgrade FAQ

Mind Q Systems Private Limited

SQL Server 2012 Database Administration With AlwaysOn & Clustering Techniques

Recovery Principles in MySQL Cluster 5.1

CASE STUDY: Oracle TimesTen In-Memory Database and Shared Disk HA Implementation at Instance level. -ORACLE TIMESTEN 11gR1

In-Memory Databases MemSQL

DBMS / Business Intelligence, SQL Server

The Hadoop Distributed File System

Physical Data Organization

Stellar Phoenix. SQL Database Repair 6.0. Installation Guide

Query Performance Tuning: Start to Finish. Grant Fritchey

Dynamics NAV/SQL Server Configuration Recommendations

Apache Derby Performance. Olav Sandstå, Dyre Tjeldvoll, Knut Anders Hatlen Database Technology Group Sun Microsystems

Jason S Wong Sr. DBA IT Applications Manager DBA Developer Programmer M.S. Rice 88, MBA U.H. 94(MIS)

Comp 5311 Database Management Systems. 16. Review 2 (Physical Level)

Performance Verbesserung von SAP BW mit SQL Server Columnstore

SQL Server 2008 Designing, Optimizing, and Maintaining a Database Session 1

MOC 20462C: Administering Microsoft SQL Server Databases

SQL 2014 CTP1. Hekaton & CSI Version 2 unter der Lupe. Sascha Götz Karlsruhe, 03. Dezember 2013

VirtualCenter Database Performance for Microsoft SQL Server 2005 VirtualCenter 2.5

Lecture 5: GFS & HDFS! Claudia Hauff (Web Information Systems)! ti2736b-ewi@tudelft.nl

Solving Performance Problems In SQL Server by Michal Tinthofer

Microsoft SQL Server OLTP Best Practice

1 File Processing Systems

Understanding Query Processing and Query Plans in SQL Server. Craig Freedman Software Design Engineer Microsoft SQL Server

Introduction. Part I: Finding Bottlenecks when Something s Wrong. Chapter 1: Performance Tuning 3

Nimble Storage Best Practices for Microsoft SQL Server

LearnFromGuru Polish your knowledge

Execution Plans: The Secret to Query Tuning Success. MagicPASS January 2015

The Oracle Universal Server Buffer Manager

Tips and Tricks for Using Oracle TimesTen In-Memory Database in the Application Tier

SQL Server In-Memory by Design. Anu Ganesan August 8, 2014

Comparing Microsoft SQL Server 2005 Replication and DataXtend Remote Edition for Mobile and Distributed Applications

SQL Server for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

Hypertable Architecture Overview

Online Transaction Processing in SQL Server 2008

Windows NT File System. Outline. Hardware Basics. Ausgewählte Betriebssysteme Institut Betriebssysteme Fakultät Informatik

The Bw-Tree Key-Value Store and Its Applications to Server/Cloud Data Management in Production

Workflow Templates Library

Cache Configuration Reference

MS Designing and Optimizing Database Solutions with Microsoft SQL Server 2008

Outline. Windows NT File System. Hardware Basics. Win2K File System Formats. NTFS Cluster Sizes NTFS

The Google File System

Transcription:

Hekaton: SQL Server s Memory-Optimized OLTP Engine Cristian Diaconu, Craig Freedman, Erik Ismert, Per-Åke Larson, Pravin Mittal, Ryan Stonecipher, Nitin Verma, Mike Zwilling Microsoft {cdiaconu, craigfr, eriki, palarson, pravinm, ryanston, nitinver, mikezw}@microsoft.com Presented by: Prateek Gulati 1

Agenda Why do you need in-memory processing? Hekaton engine overview How it is done Benefits Limitations 2

Industry Trends: CPU Computing power holds Moore Law due to parallelism CPU clock frequency stalled Parallel processing has its limits due to lock contention 3

Industry Trends: RAM RAM prices continue to fall Servers have HUGE memory DDR4 expected to hit mainstream in 2014-2015 Traditional page based architecture has limitations, even when all pages are in memory 1000000 100000 $ per GB of PC Class Memory US$/GB 10000 1000 100 10 1 1990 1991 1992 1993 1994 1994 1995 1996 1997 1998 1999 2000 2000 2001 2002 2004 2005 2007 2008 2009 2011 4

Hekaton-In-memory OLTP engine Architecture Main-Memory Optimized T-SQL Compiled to Machine Code High Concurrency SQL Server Integration Architectural Pillars Optimized for inmemory data Memory optimized Indexes (hash and range) exist only in memory No buffer pool, B- trees Stream-based storage Transaction log optimization (block writes, no undo) T-SQL compiled to machine code via C code generator and VC Invoking a procedure is just a DLL entrypoint Aggressive optimizations at compile-time Multi-version optimistic concurrency control (MVCC) with full ACID support Core engine uses non blocking lock-free algorithms No lock manager, latches or spinlocks No TempDB Same manageability, administration & development experience Integrated queries & transactions Integrated backup/ restore If SQL Server crashes data is fully recoverable. 5

Hekaton Integration with SQL Server 6

Native Compilation Process Compile T-SQL statements and table data access logic into machine code DLL sqlservr.exe Create table/proc/ variable SQL Engine In-Memory Compiler.c file VC++ compiler/ linker Parser/Algebrizer/ Metadata/Query Optimizer Optimized query tree / metadata code generation 7

Native Compiled Stored Procedures Interpreted T-SQL Access Access both memory- and diskbased tables Less performant Virtually all T-SQL functions supported When to use Ad hoc queries Reporting-style queries Speeding up app migration Natively Compiled Procs Access only memory optimized tables Maximum performance Limited T-SQL functions supported When to use OLTP-style operations Optimize performance critical business logic More the logic embedded, better the performance improvement 8

In-Memory OLTP Structures summary Rows Row structure is optimized for memory access There are no Pages Rows are versioned and there are no in-place updates Fully durable by default (but they don t have to be) Indexes There is no clustered index, only non-clustered indexes Indexes point to rows, access to rows is via an index Indexes do not exist on disk, only in memory, recreated during recovery Hash indexes for point lookups Range indexes for ordered scans and Range Scans 9

In-Memory Row Format Row Header Payload (Actual column data) Begin Ts End Ts StmtID 8 bytes 8 bytes 4 bytes IdsLinkCou nt 2 bytes + 2 for padding Index1 ptr Index2 ptr 8 bytes * Number of Indexes Begin/End timestamp determines row s version validity and visibility No concept of data pages, only rows exist Row size limited to 8060 bytes (@table create time) to allow data to be moved to disk-based tables Not every SQL table schema is supported (Ex: LOB and SqlVariant) 10

Hash Indexes 11

Non Clustered (Range) Index Page Mapping Table 0 1 2 3 PAGE PAGE Physic al PageID-3 Root 10 20 28 PageID-0 PageID-5 4 8 10 11 15 18 21 24 27 No latch for page updates No in-place updates on index pages Page size- up to 8K. Sized to the row Sibling pages linked one direction No covering columns (only the key is stored) Non-leaf pages PageID-6 Logical PageID-15 1 2 4 5 6 7 25 26 27 Leaf pages 14 15 200, 1 50, 300 2 100, 200 1 Key Key Data rows 12

Memory Optimized Table Insert Timestamps Chain ptrs Name City Hash index on Name f(john) 50, Jane Prague 100, John Prague Hash index on City f(prague) 90, Susan Bogota T100: INSERT (John, Prague) 13

Memory Optimized Table Update Timestamps Chain ptrs Name City Hash index on Name f(john) 50, Jane Prague 100, 200 John Prague 200, John Beijing Hash index on City f(beijing) 90, 150 Susan Bogota T200: UPDATE (John, Prague) to (John, Beijing) 14

Memory Optimized Table Delete Timestamps Chain ptrs Name City Hash index on Name 50, Jane Prague Hash index on City 100, John Prague 90, 150 Susan Bogota T150: DELETE (Susan, Bogota) 15

Transaction Durability Transaction durability is ensured to allows system to recover memoryoptimized table after a failure. Log streams contain the effects of committed transactions logged as insertion and deletion of row versions Checkpoint streams come in two forms: a) data streams which contain all inserted versions during a timestamp interval, b) delta streams, each of which is associated with a particular data stream and contains a dense list of integers identifying deleted versions for its corresponding data stream Hekaton table can be durable or non-durable Stored in a single memory-optimized FILEGROUP based on FILESTREAM implementation Sequential IO pattern (no random IO) 16

Transaction Logging Uses database s transaction log to store content Each Hekaton log record contains a transaction log record header, followed by Hekaton-specific log content All logging in Hekaton is logical No physical log records for physical structure modifications No index-specific / index-maintenance log records Redo-only log records in transaction log 17

Checkpoints Hekaton Checkpoint Not tied to recovery interval or SQL checkpoint. Has its own log truncation Gets triggered when generated log exceeds a threshold (1GB) or internal min time-threshold has crossed since last checkpoint or manual checkpoint Checkpoint is a set of {Data, Delta} files and checkpoint file inventory to apply transaction log from 18

Populating Data / Delta files Data files: Pre-allocated size (128 MB) Hekaton Engine switches to new data file when it estimates that current set of log records will fill the file Stores only the inserted rows Indexes exist only in memory, not on disk Once a data file is closed, it becomes read-only Delta files: File size is not constant, write 4KB pages over time Stores IDs of deleted rows 19

Data / Delta Files Transaction Timestamp Range 0 100 Data File Timestamp (INSERT) TableID RowID Payload Timestamp (INSERT) TableID RowID Payload Timestamp (INSERT) TableID RowID Payload Checkpoint File Pair Data file contains rows inserted within a given transaction range Delta File Timestamp (INSERT) Timestamp (DELETE) RowID Timestamp (INSERT) Timestamp (DELETE) RowID Timestamp (INSERT) Timestamp (DELETE) RowID Delta file contains deleted rows within a given transaction range 20

Merge Operation Merges 2+ adjacent data / delta files pairs into 1 pair Need for merge - Deleting rows causes data files to have stale rows Manual checkpoints closes file before it is full Reduces storage required to store active data rows Improves the recovery time Stored Procedure provided to invoke merge manually 21

Merge Operation 22

Garbage Collection Timestamps Chain ptrs Name City Hash index on Name f(jane) f(john) 50, Jane Prague 100, 200 John Prague 200, John Beijing 90, 150 Susan Bogota T250: Garbage collection 23

Cooperative Garbage Collection Scanners can remove expired rows when they come across them Offloads work from GC thread Ensures that frequently visited areas of the index are clean of expired rows TX4: Begin = 210 Oldest Active Hint = 200 100 200 1 John Smith Kirkland 200 1 John Smith Redmond 100 1 Peter Spiro Seattle 50 100 1 Jim Spring Kirkland 300 1 Ken Stone Boston 24

Performance Gains 25

Hekaton Engine s Scalability 26

Memory Optimized Table Limitations Optimized for high-throughput OLTP No XML and no CLR data types Optimized for in-memory Rows are at most 8060 bytes No Large Object (LOB) types like varchar(max) Durable memory-optimized tables are limited to 512 GB. (Non-durable tables have no size limit.) Scoping limitations No FOREIGN KEY and no CHECK constraints No schema changes (ALTER TABLE) need to drop/recreate table No add/remove index need to drop/recreate table No Computed Columns No Cross-Database Queries 27

Natively Compiled Procedures Restrictions Not all operators/tsqls are supported Only Nested Loop join, no TSQL MERGE or EXISTS, cursors, nested queries No CASE statement, CTEs, user-defined functions, UNION statement, DISTINCT statement Transaction isolation level SNAPSHOT, REPEATABLEREAD, and SERIALIZABLE READ COMMITTED and READ UNCOMMITED is not supported Cannot access disk-based tables No TEMPDB! Use In-Memory Table variables No automatic recompile on statistics changes Need to stop & start SQL or drop & create procedure 28

Create Filegroup FileGroup Container CREATE DATABASE [Hekaton] ON PRIMARY (NAME = N'Hekaton_data', FILENAME = N'C:\Data\Data\Hekaton_data.mdf'), FILEGROUP [Hekaton_InMemory] CONTAINS MEMORY_OPTIMIZED_DATA (NAME = N'Hekaton_mem', FILENAME = N'C:\Data\Mem\Hekaton_Lun1.mdf') LOG ON (NAME = N'Hekaton_log', FILENAME = N'C:\Data\Log\Hekaton_log.ldf') ALTER DATABASE [Hekaton] ADD FILE (NAME = N'Hekaton_mem', FILENAME = N'C:\Data\Mem \Hekaton_Lun2.mdf') TO FILEGROUP [Hekaton_InMemory] 29

Create Memory Optimized Table CREATE TABLE [Customer] ( Hash Index [CustomerID] INT NOT NULL PRIMARY KEY NONCLUSTERED HASH WITH (BUCKET_COUNT = 1000000), [AddressID] INT NOT NULL INDEX [IxName] HASH WITH (BUCKET_COUNT = 1000000), Collation BIN2 [LName] NVARCHAR(250) COLLATE Latin1_General_100_BIN2 NOT NULL INDEX [IXLName] NONCLUSTERED (LName) ) Range Index WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA); This table is memory optimized This table is durable 30

References http://www.enterprisetech.com/2014/03/18/microsoft-turbocharges-transactions-hekaton-memory/ http://blogs.msdn.com/b/sqlcat/archive/2013/06/25/sql-server-in-memory-oltp-internals-overviewfor-ctp1.aspx http://blogs.msdn.com/b/arvindsh/archive/2013/07/03/sql-2014-in-memory-oltp-hekaton-trainingvideos-and-white-papers.aspx https://www.simple-talk.com/sql/database-administration/exploring-in-memory-oltp-engine- (hekaton)-in-sql-server-2014-ctp1/ http://www.sqlskills.com/blogs/bobb/category/hekaton/ http://thomaslarock.com/2013/08/sql-server-2014-in-memory-oltp-hekaton-useful-links http://blogs.msdn.com/b/carlnol/archive/2013/09/16/implementing-lob-storage-in-memoryoptimized-tables.aspx http://www.sqlpassion.at/archive/2013/08/12/extreme-transaction-processing-xtp-hekaton-thesolution-to-everything/ http://mattsql.wordpress.com/2013/07/08/in-memory-oltp-with-sql-server-2014/ http://research.microsoft.com/en-us/news/features/hekaton-122012.aspx www.slideshare.net/raviokade/ 31

Thank you for your time! Q&A? 32