IN Memory Oltp hash index vs non clustered

1.5k views Asked by At

SQL 2014 memory tables supports two type of indexes ,hash non clustered,non clustered.Since memory optimized tables are not stored as rows,we need to have one index compulosary.Below is the syntax to create hash index

CREATE TABLE dbo.sample_memoryoptimizedtable_Hash
(
 c1 int NOT NULL,
 c2 float NOT NULL,
 c3 decimal(10, 2) NOT NULL
CONSTRAINT PK_sample_memoryoptimizedtable_Hash **PRIMARY KEY NONCLUSTERED HASH**
(
 c1 
)WITH ( BUCKET_COUNT = 1024)
)WITH ( MEMORY_OPTIMIZED = ON , DURABILITY = SCHEMA_AND_DATA )
GO

Above statement creates a hash index and stores respective rows into their buckets .Buckets contain pointers to memory address of data.

But when we create non clustered index with below defition

CREATE TABLE dbo.sample_memoryoptimizedtable_Range
(
 c1 int NOT NULL,
 c2 float NOT NULL,
 c3 decimal(10, 2) NOT NULL
CONSTRAINT PK_sample_memoryoptimizedtable_Range PRIMARY KEY NONCLUSTERED 
(
 c1 ASC
) 
)WITH ( MEMORY_OPTIMIZED = ON , DURABILITY = SCHEMA_AND_DATA )
GO

How the above index is stored,is this stored as B tree ,since this index is not hashed and tables ,indexes are recreated on startup.How SQL stores the data.

Below are the best links and my analysis for far.

http://www.mssqltips.com/sqlservertip/3099/understanding-sql-server-memoryoptimized-tables-hash-indexes/

1

There are 1 answers

1
keseph On BEST ANSWER

The "non-clustered" indexes you're referring to are actually Range indexes. Both Hash and Range indexes are non-clustered, and there are no "clustered" indexes in in-memory OLTP tables (the primary key is forcibly implemented as a clustered hash index). Range indexes are implemented via modified B-trees and you can read more about the underlying details of both on the sigmod whitepaper at http://research.microsoft.com/pubs/193594/Hekaton%20-%20Sigmod2013%20final.pdf