I am using SQL Server 2014 CTP2, with READ_COMMITTED_SNAPSHOT ON (I think it's important for the question).
I have create an In-Memory table type (very similar to the example the technet blog, SQL Server 2014 In Memory OLTP: Memory-Optimized Table Types and Table Variables), and I have several In-Memory tables.
In the query itself I have a join between the regular In-Memory tables and the In-Memory table type, acting as a filter, when I execute the query I get this error message: "A query that accesses memory optimized tables using the READ COMMITTED isolation level, cannot access disk based tables when the database option READ_COMMITTED_SNAPSHOT is set to ON. Provide a supported isolation level for the memory optimized table using a table hint, such as WITH (SNAPSHOT)."
I'm removing the READ_COMMITTED_SNAPSHOT ON as I'm writing this question, but the question remains, If I have created a In-Memory data type, and this specific type will "never spill to disk", as the blog says, why does the server "see" it as a "disk table?
To clear things up, I have tried to do the join with only In-Mem tables and it works, as soon as the table type came in I got the error.
Update: when I removed the READ_COMMITTED_SNAPSHOT (now it's off) the query works, but now I have lost multi-version/no lock/speed, I would like to hear another solution.
Thanks
Steps to reproduce.
Create a database with a memory optimised file group
CREATE DATABASE MemOptimized
GO
ALTER DATABASE MemOptimized
ADD FILEGROUP mofg
CONTAINS MEMORY_OPTIMIZED_DATA
GO
ALTER DATABASE MemOptimized
ADD FILE ( NAME = N'mofg',
FileName = N'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\MemOptimized.ndf')
TO FILEGROUP mofg
Create some objects
CREATE TYPE [dbo].[tType] AS TABLE(
[C] [int] NOT NULL
INDEX ix NONCLUSTERED HASH (C) WITH (BUCKET_COUNT = 8)
) WITH ( MEMORY_OPTIMIZED = ON )
CREATE TABLE [dbo].[tTable] (
[C] [int] NOT NULL PRIMARY KEY NONCLUSTERED HASH WITH (BUCKET_COUNT = 8)
) WITH ( MEMORY_OPTIMIZED = ON )
INSERT INTO [dbo].[tTable] VALUES(1)
GO
CREATE PROC P
AS
DECLARE @t [dbo].[tType]
INSERT INTO @t
VALUES (1)
SELECT *
FROM [dbo].[tTable] t
INNER JOIN @t
ON [@t].C = t.C
The following works without error
ALTER DATABASE [MemOptimized]
SET READ_COMMITTED_SNAPSHOT OFF WITH ROLLBACK IMMEDIATE
GO
USE MemOptimized
EXEC P
But this
ALTER DATABASE [MemOptimized]
SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE
GO
USE MemOptimized
EXEC P
Gives the error detailed above
Msg 41359, Level 16, State 0, Procedure P, Line 62 A query that accesses memory optimized tables using the READ COMMITTED isolation level, cannot access disk based tables when the database option READ_COMMITTED_SNAPSHOT is set to ON. Provide a supported isolation level for the memory optimized table using a table hint, such as WITH (SNAPSHOT).