In-Memory OLTP — Complete Guide
In-Memory OLTP — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of SQL Server Tutorial on Toolliyo Academy.
On this page
SQL Server Tutorial · Lesson 65 of 100
In-Memory OLTP
SQL basics ✓ → Queries ✓ → Advanced
Advanced · 3 — Procedures · ~10 min · SQL — Advanced SQL Server
What is this?
In-Memory OLTP (Hekaton) stores memory-optimized tables and natively compiled procedures for extreme transactional throughput with different durability options.
Why should you care?
Session/state or high-frequency trading style tables sometimes need it — not every ordinary Orders table.
See it live — copy this example
Run in SQL Server Management Studio (SSMS) or Azure Data Studio.
USE DataVerse;
-- Requires MEMORY_OPTIMIZED_DATA filegroup (setup omitted if not present)
-- CREATE TABLE dbo.CartSessions (
-- SessionId UNIQUEIDENTIFIER NOT NULL PRIMARY KEY NONCLUSTERED,
-- Payload NVARCHAR(MAX) NOT NULL,
-- LastTouch DATETIME2 NOT NULL
-- ) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_AND_DATA);
What happened?
- Commented template shows MEMORY_OPTIMIZED = ON.
- You must add a memory-optimized filegroup first.
- Start only when a measured bottleneck justifies the complexity.
Practice next
- Check if your edition supports In-Memory OLTP.
- Read filegroup requirements in docs.
- Prototype a tiny session table in lab if available.
- Compare DURABILITY = SCHEMA_ONLY vs SCHEMA_AND_DATA meanings.
- List memory-optimized tables via sys.tables.is_memory_optimized.
Remember
In-Memory OLTP is specialized. Needs special filegroups. Use for proven hot spots.
Cart session hotspot
DataVerse stores ephemeral cart sessions in memory-optimized tables.
Outcome: Checkout staging handles spikes; durable orders stay on disk tables.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!