I see this as well.
When RCSI is enabled then auto commit transactions at default read committed level work fine when joining together two instances of the in memory table type.
DECLARE @t1 [dbo].[tType]
DECLARE @t2 [dbo].[tType]
INSERT INTO @t1 VALUES (1);
INSERT INTO @t2 VALUES (1);
SELECT *
FROM @t1
JOIN @t2
ON [@t1].C = [@t2].C
Also joining two different "normal" memory-optimized tables works fine without any hints.
Additionally joining an empty memory-optimized table type to a normal memory-optimized table works fine.
DECLARE @t [dbo].[tType];
SELECT *
FROM [dbo].[tTable] t
INNER JOIN @t
ON [@t].C = t.C
But the reverse is not true. As long as the in memory table type instance contains at least one row then joining it to an (empty or otherwise) in memory table raises the error.
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).
The solution is simple and is indicated in the error message. Just add the table hint WITH (SNAPSHOT)
DECLARE @t [dbo].[tType]
INSERT INTO @t
VALUES (1)
SELECT *
FROM [dbo].[tTable] t WITH(SNAPSHOT)
INNER JOIN @t
ON [@t].C = t.C
Or a less granular solution is
ALTER DATABASE [MemOptimized]
SET MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT = ON WITH ROLLBACK IMMEDIATE
which will set the isolation level for memory-optimized tables to
SNAPSHOT
(as if you includedWITH(SNAPSHOT)
hints to every memory-optimized table) Source
As far as I can gather neither of these actually change the semantics and the ability to omit the hint in some circumstances is just a programming convenience.
For autocommit transactions, the isolation level
READ COMMITTED
is implicitly mapped toSNAPSHOT
for memory-optimized tables. Therefore, if theTRANSACTION ISOLATION LEVEL
session setting is set toREAD COMMITTED
, it is not necessary to specify the isolation level through a table hint when accessing memory-optimized tables. SourceThe isolation level
READ COMMITTED
is supported for memory-optimized tables with autocommit transactions.READ COMMITTED
is not supported with explicit or implicit user transactions. Isolation levelREAD_COMMITTED_SNAPSHOT
is supported for memory-optimized tables with autocommit transactions and only if the query does not access any disk-based tables. Source
I'm not sure why this mix of different in memory table types causes this particular error message. I assume it is just an artefact of being a CTP and that at RTM either the combination will be allowed or the error message and documentation will be updated to refer not just to disk based tables.