SlideShare a Scribd company logo
SQL Server 2014 In-Memory Tables
(Extreme Transaction Processing)
Basics
Tony Rogerson, SQL Server MVP
@tonyrogerson
tonyrogerson@torver.net
http://www.sql-server.co.uk
Who am I?
• Freelance SQL Server professional and Data Specialist
• Fellow BCS, MSc in BI, PGCert in Data Science
• Started out in 1986 – VSAM, System W, Application System, DB2,
Oracle, SQL Server since 4.21a
• Awarded SQL Server MVP yearly since 97
• Founded UK SQL Server User Group back in ’99, founder member
of DDD, SQL Bits, SQL Relay, SQL Santa and Project Mildred
• Interested in commodity based distributed processing of Data.
• I have an allotment where I grow vegetables - I do not do any
analysis on how they grow, where they grow etc. My allotment is
where I escape technology.
Agenda
• Define concept “In-Memory”
• Implementation
– Storage
– Memory, Buffer Pool and using Resource Pools
– Memory Optimised Tables and Index Types
– Native Stored Procedures
• Queries
• HA / DR
• Planning
DEFINE
“In-Memory”
What is IMDB / DBIM / IMT?
• Entire database resides in Main memory
• Hybrid - selective tables reside entirely in memory
• Row / Column store
– Oracle keeps two copies of the data – in row AND column store –
optimiser chooses, no app change required
– SQL Server 2014 you choose –
• Columnstore (Column Store Indexing) – traditionally for OLAP
• Rowstore (memory optimised table with hash or range index) – traditionally
for OLTP
• Non-Volatile Memory changes everything – it’s here now!
– SQL Server 2014 Buffer Pool Extensions
SQL Server “in-memory”
• Column Store (designed for OLAP)
– Column compression to reduce memory required
– SQL 2012:
• One index per table, nonclustered only, table read-only
– SQL 2014:
• Only index on table – clustered, table is now updateable
• Memory Optimised Tables (designed for OLTP)
– Standard CREATE TABLE with restrictions on FK’s and other
constraints
IMPLEMENTATION
FILESTREAM underpins XTP
Storage - FILESTREAM
Storage - FILESTREAM
DEMO
• CREATE DATABASE.sql
RAW DATA
on Storage
(no index data)
Memory
Raw
Data
Build
Range
and
Hash
Indexes
Queryable
Database Recovery
• Make sure the IO Sub-system can handle the load – it will swamp
the IO Sub-System
• Only the Raw Data is stored – no need to hold indexes (everything
fits in memory!)
SQL Server Memory Pools
Stable
Storage
(MDF/NDF
Files)
Buffer Pool
Table
Data Data in/out as required
Memory Internal Structures (proc/log
cache etc.)
SQL Server
Memory
Space
SQL Server Memory Pools
Stable
Storage
(MDF/NDF
Files)
Buffer Pool
Table
Data Data in/out as required
Memory Internal Structures (proc/log
cache etc.)
SQL Server
Memory
Space
Memory Optimised Tables
Create Resource Pool
CREATE RESOURCE POOL mem_xtp_pool
WITH ( MAX_MEMORY_PERCENT = 50,
MIN_MEMORY_PERCENT = 50
);
ALTER RESOURCE GOVERNOR RECONFIGURE;
EXEC sp_xtp_bind_db_resource_pool 'xtp_demo', 'mem_xtp_pool';
ALTER DATABASE xtp_demo SET OFFLINE WITH ROLLBACK IMMEDIATE;
ALTER DATABASE xtp_demo SET ONLINE;
Best
Practice
DEMO
• RESOURCE POOL.sql
MEMORY OPTIMISED TABLE
Table Structure
• New option on WITH (
– MEMORY_OPTIMIZED = ON
– DURABILITY = SCHEMA_AND_DATA | SCHEMA_ONLY
)
• Maximum 8 indexes per table
• Choice of two index types:
– Hash (only good for equality expressions)
– Range (good for everything)
Table Structure
• Compiled to .C structure
• Cannot ALTER TABLE – only DROP/CREATE
• Data is stored in FILESTREAM files (not MDF)
• Logging still done to LDF (SCHEMA_AND_DATA only)
• Statistics are not automatically updated – require:
– UPDATE STATISTICS {table} WITH FULLSCAN,
NORECOMPUTE, ALL
Table Declaration
• IDENTITY( 1, 1 ) only – use SEQUENCE if not suitable
• DEFAULT constraints ok
• No Foreign Key constraints
• No Check constraints
• No UNIQUE constraints – only PRIMARY KEY allowed
• CREATE VIEW works (but view not usable from Native
Stored Procedure)
Useful DMV’s
• sys.hash_indexes
• sys.dm_db_xtp_hash_index_stats
• sys.dm_db_xtp_table_memory_stats
• sys.dm_db_xtp_index_stats
• sys.dm_db_xtp_object_stats
DEMO
• CREATE TABLE.sql
• DML.sql
Hash Index and Row Chains
BUCKET_COUNT options
1024 – 8 kilobytes
2048 – 16 kilobytes
4096 – 32 kilobytes
8192 – 64 kilobytes
16384 – 128 kilobytes
32768 – 256 kilobytes
65536 – 512 kilobytes
131072 – 1 megabytes
262144 – 2 megabytes
524288 – 4 megabytes
1048576 – 8 megabytes
2097152 – 16 megabytes
4194304 – 32 megabytes
8388608 – 64 megabytes
16777216 – 128 megabytes
33554432 – 256 megabytes
67108864 – 512 megabytes
134217728 – 1,024 megabytes
268435456 – 2,048 megabytes
536870912 – 4,096 megabytes
1073741824 – 8,192 megabytes
Range Index (Bw Tree ≈ B+Tree)
8KiB
1 row tracks a page
in level below
Root
Leaf
Leaf row per table row
{index-col}{pointer}
Bw TreeB+Tree
8KiB
Root
Leaf
Leaf row per unique value
{index-col}{memory-pointer}
Row Chain
DEMO
• INDEXING.sql
Index recommendations
• Use HASH when
– Mostly unique values
– Query uses expressions “Equality” i.e. = or !=
– Set BUCKET_COUNT appropriately
– Seriously think if you are considering composite index
• Use RANGE when
– Expressions are not Equality e.g. < > between
– Composite Index
– Low Cardinality
Best
Practice
Multi-Version Concurrency Control (MVCC)
• Compare And Swap replaces Latching
• Update is actually INSERT and Tombstone
• Row Versions [kept in memory]
• Garbage collection task cleans up versions no longer required (stale
data rows)
• Versions no longer required determined by active transactions – may
be inter-connection dependencies
• Your in-memory table can double, triple, x 100 etc. in size depending
on access patterns (data mods + query durations)
• Row chains can expand dramatically and cause really poor
performance
Versions in the Row Chain
Newest
Oldest
TS_START TS_END Connection
2 NULL 55
7 NULL 60
50 NULL 80
Versions in the Row Chain
Newest
Oldest
TS_START TS_END Connection
2 10 55
7 NULL 60
50 NULL 80
Tombstone
Versions in the Row Chain
Current
TS_START TS_END Connection
2 NULL 55
7 NULL 60
50 NULL 80
Tombstone
Natively Compiled Procedures
• Compiled via C code
• Table statistics [which are not auto-updated] used when
proc is created
• {very}Restricted functionality (they are working on it)
• Massive speed improvements possible
DEMO
• NATIVE PROCS.sql
QUERYING
Understanding Isolation and mixing memory optimised and storage optimised tables
SNAPSHOT Isolation
• Your connection has a Snapshot of the Data that you just
read – Snapshot is persistent and isolated from other
connections using Versioning (MVCC).
• Default SQL Server isolation is READ COMMITTED
• Inside a transaction you must specify WITH ( SNAPSHOT ) to
override the default isolation level
• Cannot use SET TRANSACTION ISOLATION SNAPSHOT
with transactions and in-memory tables
• MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT
database setting
DEMO
• QUERYING.sql
Querying (interop)
• Not supported:
– Linked Tables
– Cross database joins (except table vars and temp tables)
– Reference from indexed view
– MERGE (memory optimised table as target)
– TRUNCATE TABLE
– CLR using context connection
– A load of table hints, see: http://msdn.microsoft.com/en-
us/library/dn133177.aspx
• Must use WITH ( SNAPSHOT ) when statement is not auto-
commit.
HADR - DEMO
• HADR.sql
Backup / Restore
• Meta-data only for Non-Durable tables (no data!)
• Backup is self-contained
– Full backup
– Differentials
– Logs
– Restore in Standby
• Remember
– Data is loaded into memory on recovery [standby performs a semi-
recovery]
– Make sure you have enough memory on the secondary
Availability Groups
• Yep – they work too
• Differs from Log restore
– Data and Indexes already in memory
• Readable secondary replica’s work
• SCHEMA_ONLY (Non-Durable) tables will be empty!
PLANNING
Thinking through the possibilities
Migration - DEMO
• Table: Memory Optimiser Advisor
• Stored Procedure: Native Compilation Advisor
Migrating Tables
• Throw it all in memory?
– Probably not a good idea!
• Partition through View – mix memory and storage
optimised
• Only index what you need + monitor and remove ones not
required
• Application Transaction duration/number of updates
suitable?
SQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics
SQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics
SQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics

More Related Content

What's hot

Best Oracle dba online training institute
Best Oracle dba online training instituteBest Oracle dba online training institute
Best Oracle dba online training institute
Mindmajix Technologies
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
Tuyen Vuong
 
Optimizing MySQL for Cascade Server
Optimizing MySQL for Cascade ServerOptimizing MySQL for Cascade Server
Optimizing MySQL for Cascade Server
hannonhill
 
MySQL Performance - Best practices
MySQL Performance - Best practices MySQL Performance - Best practices
MySQL Performance - Best practices
Ted Wennmark
 
PostgreSQL as an Alternative to MSSQL
PostgreSQL as an Alternative to MSSQLPostgreSQL as an Alternative to MSSQL
PostgreSQL as an Alternative to MSSQL
Alexei Krasner
 
MySQL database
MySQL databaseMySQL database
MySQL database
lalit choudhary
 
Conquering "big data": An introduction to shard query
Conquering "big data": An introduction to shard queryConquering "big data": An introduction to shard query
Conquering "big data": An introduction to shard query
Justin Swanhart
 
MySQL For Oracle Developers
MySQL For Oracle DevelopersMySQL For Oracle Developers
MySQL For Oracle Developers
Ronald Bradford
 
Ora mysql bothGetting the best of both worlds with Oracle 11g and MySQL Enter...
Ora mysql bothGetting the best of both worlds with Oracle 11g and MySQL Enter...Ora mysql bothGetting the best of both worlds with Oracle 11g and MySQL Enter...
Ora mysql bothGetting the best of both worlds with Oracle 11g and MySQL Enter...
Ivan Zoratti
 
San in depth
San in depthSan in depth
San in depth
sagaroceanic11
 
Database storage engines
Database storage enginesDatabase storage engines
Database storage engines
University of Sindh, Jamshoro
 
No sql databases
No sql databasesNo sql databases
No sql databases
swathika rajan
 
InnoDB Architecture and Performance Optimization, Peter Zaitsev
InnoDB Architecture and Performance Optimization, Peter ZaitsevInnoDB Architecture and Performance Optimization, Peter Zaitsev
InnoDB Architecture and Performance Optimization, Peter Zaitsev
Fuenteovejuna
 
Shard-Query, an MPP database for the cloud using the LAMP stack
Shard-Query, an MPP database for the cloud using the LAMP stackShard-Query, an MPP database for the cloud using the LAMP stack
Shard-Query, an MPP database for the cloud using the LAMP stack
Justin Swanhart
 
01 upgrade to my sql8
01 upgrade to my sql8 01 upgrade to my sql8
01 upgrade to my sql8
Ted Wennmark
 

What's hot (15)

Best Oracle dba online training institute
Best Oracle dba online training instituteBest Oracle dba online training institute
Best Oracle dba online training institute
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
 
Optimizing MySQL for Cascade Server
Optimizing MySQL for Cascade ServerOptimizing MySQL for Cascade Server
Optimizing MySQL for Cascade Server
 
MySQL Performance - Best practices
MySQL Performance - Best practices MySQL Performance - Best practices
MySQL Performance - Best practices
 
PostgreSQL as an Alternative to MSSQL
PostgreSQL as an Alternative to MSSQLPostgreSQL as an Alternative to MSSQL
PostgreSQL as an Alternative to MSSQL
 
MySQL database
MySQL databaseMySQL database
MySQL database
 
Conquering "big data": An introduction to shard query
Conquering "big data": An introduction to shard queryConquering "big data": An introduction to shard query
Conquering "big data": An introduction to shard query
 
MySQL For Oracle Developers
MySQL For Oracle DevelopersMySQL For Oracle Developers
MySQL For Oracle Developers
 
Ora mysql bothGetting the best of both worlds with Oracle 11g and MySQL Enter...
Ora mysql bothGetting the best of both worlds with Oracle 11g and MySQL Enter...Ora mysql bothGetting the best of both worlds with Oracle 11g and MySQL Enter...
Ora mysql bothGetting the best of both worlds with Oracle 11g and MySQL Enter...
 
San in depth
San in depthSan in depth
San in depth
 
Database storage engines
Database storage enginesDatabase storage engines
Database storage engines
 
No sql databases
No sql databasesNo sql databases
No sql databases
 
InnoDB Architecture and Performance Optimization, Peter Zaitsev
InnoDB Architecture and Performance Optimization, Peter ZaitsevInnoDB Architecture and Performance Optimization, Peter Zaitsev
InnoDB Architecture and Performance Optimization, Peter Zaitsev
 
Shard-Query, an MPP database for the cloud using the LAMP stack
Shard-Query, an MPP database for the cloud using the LAMP stackShard-Query, an MPP database for the cloud using the LAMP stack
Shard-Query, an MPP database for the cloud using the LAMP stack
 
01 upgrade to my sql8
01 upgrade to my sql8 01 upgrade to my sql8
01 upgrade to my sql8
 

Viewers also liked

San Francisco SQL Server User Group Meeting Feb 2009
San Francisco SQL Server User Group Meeting Feb 2009San Francisco SQL Server User Group Meeting Feb 2009
San Francisco SQL Server User Group Meeting Feb 2009
Mark Ginnebaugh
 
Go Faster With Native Compilation
Go Faster With Native CompilationGo Faster With Native Compilation
Go Faster With Native Compilation
Rajeev Rastogi (KRR)
 
Fard Solutions Sdn Bhd
Fard Solutions Sdn Bhd Fard Solutions Sdn Bhd
Fard Solutions Sdn Bhd
Hamid J. Fard
 
Data Platform Overview
Data Platform OverviewData Platform Overview
Data Platform Overview
Hamid J. Fard
 
SSD Caching
SSD CachingSSD Caching
SSD Caching
Israel Gold
 
Quack Chat | Partitioning - Black Magic or Silver Bullet
Quack Chat | Partitioning - Black Magic or Silver BulletQuack Chat | Partitioning - Black Magic or Silver Bullet
Quack Chat | Partitioning - Black Magic or Silver Bullet
IDERA Software
 
Otimizando a performance com in memory no sql 2016
Otimizando a performance com in memory no sql 2016Otimizando a performance com in memory no sql 2016
Otimizando a performance com in memory no sql 2016
Luiz Henrique Garetti Rosário
 
SQL Server - Inside Optimizer Engine
SQL Server - Inside Optimizer EngineSQL Server - Inside Optimizer Engine
SQL Server - Inside Optimizer Engine
Hamid J. Fard
 

Viewers also liked (8)

San Francisco SQL Server User Group Meeting Feb 2009
San Francisco SQL Server User Group Meeting Feb 2009San Francisco SQL Server User Group Meeting Feb 2009
San Francisco SQL Server User Group Meeting Feb 2009
 
Go Faster With Native Compilation
Go Faster With Native CompilationGo Faster With Native Compilation
Go Faster With Native Compilation
 
Fard Solutions Sdn Bhd
Fard Solutions Sdn Bhd Fard Solutions Sdn Bhd
Fard Solutions Sdn Bhd
 
Data Platform Overview
Data Platform OverviewData Platform Overview
Data Platform Overview
 
SSD Caching
SSD CachingSSD Caching
SSD Caching
 
Quack Chat | Partitioning - Black Magic or Silver Bullet
Quack Chat | Partitioning - Black Magic or Silver BulletQuack Chat | Partitioning - Black Magic or Silver Bullet
Quack Chat | Partitioning - Black Magic or Silver Bullet
 
Otimizando a performance com in memory no sql 2016
Otimizando a performance com in memory no sql 2016Otimizando a performance com in memory no sql 2016
Otimizando a performance com in memory no sql 2016
 
SQL Server - Inside Optimizer Engine
SQL Server - Inside Optimizer EngineSQL Server - Inside Optimizer Engine
SQL Server - Inside Optimizer Engine
 

Similar to SQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics

SQL Server 2014 In-Memory OLTP
SQL Server 2014 In-Memory OLTPSQL Server 2014 In-Memory OLTP
SQL Server 2014 In-Memory OLTP
Tony Rogerson
 
SQL Server and SharePoint - Best Practices presented by Steffen Krause, Micro...
SQL Server and SharePoint - Best Practices presented by Steffen Krause, Micro...SQL Server and SharePoint - Best Practices presented by Steffen Krause, Micro...
SQL Server and SharePoint - Best Practices presented by Steffen Krause, Micro...
European SharePoint Conference
 
Revision
RevisionRevision
Revision
David Sherlock
 
Introduction to SharePoint for SQLserver DBAs
Introduction to SharePoint for SQLserver DBAsIntroduction to SharePoint for SQLserver DBAs
Introduction to SharePoint for SQLserver DBAs
Steve Knutson
 
MySQL Optimization from a Developer's point of view
MySQL Optimization from a Developer's point of viewMySQL Optimization from a Developer's point of view
MySQL Optimization from a Developer's point of view
Sachin Khosla
 
SQLServer Database Structures
SQLServer Database Structures SQLServer Database Structures
SQLServer Database Structures
Antonios Chatzipavlis
 
2008 2086 Gangler
2008 2086 Gangler2008 2086 Gangler
2008 2086 Gangler
Secure-24
 
JSSUG: SQL Sever Performance Tuning
JSSUG: SQL Sever Performance TuningJSSUG: SQL Sever Performance Tuning
JSSUG: SQL Sever Performance Tuning
Kenichiro Nakamura
 
Novedades SQL Server 2014
Novedades SQL Server 2014Novedades SQL Server 2014
Novedades SQL Server 2014
netmind
 
MYSQL Query Anti-Patterns That Can Be Moved to Sphinx
MYSQL Query Anti-Patterns That Can Be Moved to SphinxMYSQL Query Anti-Patterns That Can Be Moved to Sphinx
MYSQL Query Anti-Patterns That Can Be Moved to Sphinx
Pythian
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
Malin Weiss
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
Speedment, Inc.
 
Oracle dba 12c training syllabus
Oracle dba 12c training syllabusOracle dba 12c training syllabus
Oracle dba 12c training syllabus
Monster Courses
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
WrushabhShirsat3
 
unit-ii.pptx
unit-ii.pptxunit-ii.pptx
unit-ii.pptx
NilamHonmane
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
Iftikhar70
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
subbu998029
 
MariaDB ColumnStore
MariaDB ColumnStoreMariaDB ColumnStore
MariaDB ColumnStore
MariaDB plc
 
Sql Server2008
Sql Server2008Sql Server2008
Sql Server2008
Microsoft Iceland
 
SQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and EnhancementsSQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and Enhancements
John Martin
 

Similar to SQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics (20)

SQL Server 2014 In-Memory OLTP
SQL Server 2014 In-Memory OLTPSQL Server 2014 In-Memory OLTP
SQL Server 2014 In-Memory OLTP
 
SQL Server and SharePoint - Best Practices presented by Steffen Krause, Micro...
SQL Server and SharePoint - Best Practices presented by Steffen Krause, Micro...SQL Server and SharePoint - Best Practices presented by Steffen Krause, Micro...
SQL Server and SharePoint - Best Practices presented by Steffen Krause, Micro...
 
Revision
RevisionRevision
Revision
 
Introduction to SharePoint for SQLserver DBAs
Introduction to SharePoint for SQLserver DBAsIntroduction to SharePoint for SQLserver DBAs
Introduction to SharePoint for SQLserver DBAs
 
MySQL Optimization from a Developer's point of view
MySQL Optimization from a Developer's point of viewMySQL Optimization from a Developer's point of view
MySQL Optimization from a Developer's point of view
 
SQLServer Database Structures
SQLServer Database Structures SQLServer Database Structures
SQLServer Database Structures
 
2008 2086 Gangler
2008 2086 Gangler2008 2086 Gangler
2008 2086 Gangler
 
JSSUG: SQL Sever Performance Tuning
JSSUG: SQL Sever Performance TuningJSSUG: SQL Sever Performance Tuning
JSSUG: SQL Sever Performance Tuning
 
Novedades SQL Server 2014
Novedades SQL Server 2014Novedades SQL Server 2014
Novedades SQL Server 2014
 
MYSQL Query Anti-Patterns That Can Be Moved to Sphinx
MYSQL Query Anti-Patterns That Can Be Moved to SphinxMYSQL Query Anti-Patterns That Can Be Moved to Sphinx
MYSQL Query Anti-Patterns That Can Be Moved to Sphinx
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
 
Oracle dba 12c training syllabus
Oracle dba 12c training syllabusOracle dba 12c training syllabus
Oracle dba 12c training syllabus
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
 
unit-ii.pptx
unit-ii.pptxunit-ii.pptx
unit-ii.pptx
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
 
MariaDB ColumnStore
MariaDB ColumnStoreMariaDB ColumnStore
MariaDB ColumnStore
 
Sql Server2008
Sql Server2008Sql Server2008
Sql Server2008
 
SQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and EnhancementsSQL Server 2016 New Features and Enhancements
SQL Server 2016 New Features and Enhancements
 

Recently uploaded

一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
hqfek
 
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Marlon Dumas
 
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptxREUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
KiriakiENikolaidou
 
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
1tyxnjpia
 
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
eoxhsaa
 
Digital Marketing Performance Marketing Sample .pdf
Digital Marketing Performance Marketing  Sample .pdfDigital Marketing Performance Marketing  Sample .pdf
Digital Marketing Performance Marketing Sample .pdf
Vineet
 
Cell The Unit of Life for NEET Multiple Choice Questions.docx
Cell The Unit of Life for NEET Multiple Choice Questions.docxCell The Unit of Life for NEET Multiple Choice Questions.docx
Cell The Unit of Life for NEET Multiple Choice Questions.docx
vasanthatpuram
 
A gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented GenerationA gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented Generation
dataschool1
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
Vietnam Cotton & Spinning Association
 
Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024
ElizabethGarrettChri
 
How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
Alireza Kamrani
 
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdfOverview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
nhutnguyen355078
 
一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理
一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理
一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理
actyx
 
一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理
一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理
一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理
hyfjgavov
 
社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .
NABLAS株式会社
 
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理 原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
tzu5xla
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
ytypuem
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
Timothy Spann
 
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
agdhot
 
一比一原版(uob毕业证书)伯明翰大学毕业证如何办理
一比一原版(uob毕业证书)伯明翰大学毕业证如何办理一比一原版(uob毕业证书)伯明翰大学毕业证如何办理
一比一原版(uob毕业证书)伯明翰大学毕业证如何办理
9gr6pty
 

Recently uploaded (20)

一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
一比一原版爱尔兰都柏林大学毕业证(本硕)ucd学位证书如何办理
 
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
 
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptxREUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
REUSE-SCHOOL-DATA-INTEGRATED-SYSTEMS.pptx
 
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
一比一原版(Sheffield毕业证书)谢菲尔德大学毕业证如何办理
 
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
 
Digital Marketing Performance Marketing Sample .pdf
Digital Marketing Performance Marketing  Sample .pdfDigital Marketing Performance Marketing  Sample .pdf
Digital Marketing Performance Marketing Sample .pdf
 
Cell The Unit of Life for NEET Multiple Choice Questions.docx
Cell The Unit of Life for NEET Multiple Choice Questions.docxCell The Unit of Life for NEET Multiple Choice Questions.docx
Cell The Unit of Life for NEET Multiple Choice Questions.docx
 
A gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented GenerationA gentle exploration of Retrieval Augmented Generation
A gentle exploration of Retrieval Augmented Generation
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
 
Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024
 
How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
 
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdfOverview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
 
一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理
一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理
一比一原版斯威本理工大学毕业证(swinburne毕业证)如何办理
 
一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理
一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理
一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理
 
社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .社内勉強会資料_Hallucination of LLMs               .
社内勉強会資料_Hallucination of LLMs               .
 
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理 原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
 
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
 
一比一原版(uob毕业证书)伯明翰大学毕业证如何办理
一比一原版(uob毕业证书)伯明翰大学毕业证如何办理一比一原版(uob毕业证书)伯明翰大学毕业证如何办理
一比一原版(uob毕业证书)伯明翰大学毕业证如何办理
 

SQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics

  • 1.
  • 2. SQL Server 2014 In-Memory Tables (Extreme Transaction Processing) Basics Tony Rogerson, SQL Server MVP @tonyrogerson tonyrogerson@torver.net http://www.sql-server.co.uk
  • 3.
  • 4.
  • 5. Who am I? • Freelance SQL Server professional and Data Specialist • Fellow BCS, MSc in BI, PGCert in Data Science • Started out in 1986 – VSAM, System W, Application System, DB2, Oracle, SQL Server since 4.21a • Awarded SQL Server MVP yearly since 97 • Founded UK SQL Server User Group back in ’99, founder member of DDD, SQL Bits, SQL Relay, SQL Santa and Project Mildred • Interested in commodity based distributed processing of Data. • I have an allotment where I grow vegetables - I do not do any analysis on how they grow, where they grow etc. My allotment is where I escape technology.
  • 6. Agenda • Define concept “In-Memory” • Implementation – Storage – Memory, Buffer Pool and using Resource Pools – Memory Optimised Tables and Index Types – Native Stored Procedures • Queries • HA / DR • Planning
  • 8. What is IMDB / DBIM / IMT? • Entire database resides in Main memory • Hybrid - selective tables reside entirely in memory • Row / Column store – Oracle keeps two copies of the data – in row AND column store – optimiser chooses, no app change required – SQL Server 2014 you choose – • Columnstore (Column Store Indexing) – traditionally for OLAP • Rowstore (memory optimised table with hash or range index) – traditionally for OLTP • Non-Volatile Memory changes everything – it’s here now! – SQL Server 2014 Buffer Pool Extensions
  • 9. SQL Server “in-memory” • Column Store (designed for OLAP) – Column compression to reduce memory required – SQL 2012: • One index per table, nonclustered only, table read-only – SQL 2014: • Only index on table – clustered, table is now updateable • Memory Optimised Tables (designed for OLTP) – Standard CREATE TABLE with restrictions on FK’s and other constraints
  • 15. RAW DATA on Storage (no index data) Memory Raw Data Build Range and Hash Indexes Queryable Database Recovery • Make sure the IO Sub-system can handle the load – it will swamp the IO Sub-System • Only the Raw Data is stored – no need to hold indexes (everything fits in memory!)
  • 16. SQL Server Memory Pools Stable Storage (MDF/NDF Files) Buffer Pool Table Data Data in/out as required Memory Internal Structures (proc/log cache etc.) SQL Server Memory Space
  • 17. SQL Server Memory Pools Stable Storage (MDF/NDF Files) Buffer Pool Table Data Data in/out as required Memory Internal Structures (proc/log cache etc.) SQL Server Memory Space Memory Optimised Tables
  • 18. Create Resource Pool CREATE RESOURCE POOL mem_xtp_pool WITH ( MAX_MEMORY_PERCENT = 50, MIN_MEMORY_PERCENT = 50 ); ALTER RESOURCE GOVERNOR RECONFIGURE; EXEC sp_xtp_bind_db_resource_pool 'xtp_demo', 'mem_xtp_pool'; ALTER DATABASE xtp_demo SET OFFLINE WITH ROLLBACK IMMEDIATE; ALTER DATABASE xtp_demo SET ONLINE; Best Practice
  • 21. Table Structure • New option on WITH ( – MEMORY_OPTIMIZED = ON – DURABILITY = SCHEMA_AND_DATA | SCHEMA_ONLY ) • Maximum 8 indexes per table • Choice of two index types: – Hash (only good for equality expressions) – Range (good for everything)
  • 22. Table Structure • Compiled to .C structure • Cannot ALTER TABLE – only DROP/CREATE • Data is stored in FILESTREAM files (not MDF) • Logging still done to LDF (SCHEMA_AND_DATA only) • Statistics are not automatically updated – require: – UPDATE STATISTICS {table} WITH FULLSCAN, NORECOMPUTE, ALL
  • 23. Table Declaration • IDENTITY( 1, 1 ) only – use SEQUENCE if not suitable • DEFAULT constraints ok • No Foreign Key constraints • No Check constraints • No UNIQUE constraints – only PRIMARY KEY allowed • CREATE VIEW works (but view not usable from Native Stored Procedure)
  • 24. Useful DMV’s • sys.hash_indexes • sys.dm_db_xtp_hash_index_stats • sys.dm_db_xtp_table_memory_stats • sys.dm_db_xtp_index_stats • sys.dm_db_xtp_object_stats
  • 26. Hash Index and Row Chains
  • 27. BUCKET_COUNT options 1024 – 8 kilobytes 2048 – 16 kilobytes 4096 – 32 kilobytes 8192 – 64 kilobytes 16384 – 128 kilobytes 32768 – 256 kilobytes 65536 – 512 kilobytes 131072 – 1 megabytes 262144 – 2 megabytes 524288 – 4 megabytes 1048576 – 8 megabytes 2097152 – 16 megabytes 4194304 – 32 megabytes 8388608 – 64 megabytes 16777216 – 128 megabytes 33554432 – 256 megabytes 67108864 – 512 megabytes 134217728 – 1,024 megabytes 268435456 – 2,048 megabytes 536870912 – 4,096 megabytes 1073741824 – 8,192 megabytes
  • 28. Range Index (Bw Tree ≈ B+Tree) 8KiB 1 row tracks a page in level below Root Leaf Leaf row per table row {index-col}{pointer} Bw TreeB+Tree 8KiB Root Leaf Leaf row per unique value {index-col}{memory-pointer} Row Chain
  • 30. Index recommendations • Use HASH when – Mostly unique values – Query uses expressions “Equality” i.e. = or != – Set BUCKET_COUNT appropriately – Seriously think if you are considering composite index • Use RANGE when – Expressions are not Equality e.g. < > between – Composite Index – Low Cardinality Best Practice
  • 31. Multi-Version Concurrency Control (MVCC) • Compare And Swap replaces Latching • Update is actually INSERT and Tombstone • Row Versions [kept in memory] • Garbage collection task cleans up versions no longer required (stale data rows) • Versions no longer required determined by active transactions – may be inter-connection dependencies • Your in-memory table can double, triple, x 100 etc. in size depending on access patterns (data mods + query durations) • Row chains can expand dramatically and cause really poor performance
  • 32. Versions in the Row Chain Newest Oldest TS_START TS_END Connection 2 NULL 55 7 NULL 60 50 NULL 80
  • 33. Versions in the Row Chain Newest Oldest TS_START TS_END Connection 2 10 55 7 NULL 60 50 NULL 80 Tombstone
  • 34. Versions in the Row Chain Current TS_START TS_END Connection 2 NULL 55 7 NULL 60 50 NULL 80 Tombstone
  • 35. Natively Compiled Procedures • Compiled via C code • Table statistics [which are not auto-updated] used when proc is created • {very}Restricted functionality (they are working on it) • Massive speed improvements possible
  • 37. QUERYING Understanding Isolation and mixing memory optimised and storage optimised tables
  • 38. SNAPSHOT Isolation • Your connection has a Snapshot of the Data that you just read – Snapshot is persistent and isolated from other connections using Versioning (MVCC). • Default SQL Server isolation is READ COMMITTED • Inside a transaction you must specify WITH ( SNAPSHOT ) to override the default isolation level • Cannot use SET TRANSACTION ISOLATION SNAPSHOT with transactions and in-memory tables • MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT database setting
  • 40. Querying (interop) • Not supported: – Linked Tables – Cross database joins (except table vars and temp tables) – Reference from indexed view – MERGE (memory optimised table as target) – TRUNCATE TABLE – CLR using context connection – A load of table hints, see: http://msdn.microsoft.com/en- us/library/dn133177.aspx • Must use WITH ( SNAPSHOT ) when statement is not auto- commit.
  • 41. HADR - DEMO • HADR.sql
  • 42. Backup / Restore • Meta-data only for Non-Durable tables (no data!) • Backup is self-contained – Full backup – Differentials – Logs – Restore in Standby • Remember – Data is loaded into memory on recovery [standby performs a semi- recovery] – Make sure you have enough memory on the secondary
  • 43. Availability Groups • Yep – they work too • Differs from Log restore – Data and Indexes already in memory • Readable secondary replica’s work • SCHEMA_ONLY (Non-Durable) tables will be empty!
  • 45. Migration - DEMO • Table: Memory Optimiser Advisor • Stored Procedure: Native Compilation Advisor
  • 46. Migrating Tables • Throw it all in memory? – Probably not a good idea! • Partition through View – mix memory and storage optimised • Only index what you need + monitor and remove ones not required • Application Transaction duration/number of updates suitable?

Editor's Notes

  1. Far from Hekaton being an extension of DBCC PINTABLE, it’s a huge new piece of functionality that can significantly improve the scalability of various data based scenarios – not just OLTP but also ETL and real-time BI. This session will introduce Hekaton features, how and when to use it; it will be demo led giving Hekaton end-to-end: enabling it, create tables, index design, query considerations, native stored procedures, durability [or not], introduce methods of identifying what to put in memory or not.
  2. http://www.databasejournal.com/features/mssql/understanding-new-column-store-index-of-sql-server-2012.html http://msdn.microsoft.com/en-us/library/gg492088.aspx