How to List All Memory Optimized Tables in SQL Server? – Interview Question of the Week #227

Question: How do you list memory-optimized tables? Query sys.tables in the relevant database and filter is_memory_optimized = 1.

A sorted tray is ready for immediate use in front of ordinary closed storage boxes

During performance health checks, I look for suitable opportunities to use In-Memory OLTP as well as opportunities to improve existing indexes. I’ve found fewer suitable workloads than I would like. When the fit is good, it can be worth evaluating, but the inventory below doesn’t establish that fit by itself.

SELECT SCHEMA_NAME(schema_id) AS SchemaName,
       name AS TableName, is_memory_optimized,
       durability_desc, create_date, modify_date
FROM sys.tables
WHERE is_memory_optimized = 1
ORDER BY SchemaName, TableName;

The original query listed every table and displayed the memory-optimized flag. The filter makes this answer specific to memory-optimized tables. Remove it if you want both kinds in one inventory. sys.tables is a catalog view, and metadata visibility can limit which tables your account sees.

SCHEMA_AND_DATA means the memory-optimized table’s data is durable. SCHEMA_ONLY preserves the schema but not its rows across database restart. Memory-optimized tables are a specific In-Memory OLTP feature introduced in SQL Server 2014. Ordinary disk-based tables can also have data pages cached in memory; that doesn’t make them memory-optimized tables.

Balmukund Lakhani made a useful point in the explanation I originally shared: faster, cheaper RAM creates an opportunity, but durable business data still has to survive failure. The durability column is worth reading, rather than treating every in-memory table as the same thing.

Related examples

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

In-Memory OLTP, SQL DMV, SQL Memory, SQL Performance
Previous Post
When was Table Accessed Last By User? – Interview Question of the Week #226
Next Post
How Much Memory is in Locked Pages? – Interview Question of the Week #228

Related Posts

3 Comments. Leave new

  • tomwickerath
    June 4, 2019 5:09 am

    Hi Pinal,

    You wrote: “In my experience, I have found an opportunity to implement In-Memory OTLP Tables is not as much as I really would love to but whenever I find a good situation, I always recommend my clients to go for it.”

    Can you provide some basic guidelines as to what constitutes a “good situation” in your mind?

    Thank You

    Reply
  • Any suggestions on how to remove Memory Optimisation on a sql table and also delete the filegroup created by it. Without dropping the database.

    Reply
  • Leah Schneider
    January 10, 2022 9:08 pm

    This is missing table variables
    SELECT *
    FROM sys.table_types tt
    WHERE tt.is_memory_optimized = 1

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.