What migration steps and limitations should you consider when converting an existing disk based table to a memory optimized table?
Short answer
You need to review the table for any unsupported data types or features, such as certain large object types or foreign key constraints referencing regular tables, migrate the data using a process like exporting and reimporting since you generally cannot alter a table directly…
Advertisement
AModel answer
You need to review the table for any unsupported data types or features, such as certain large object types or foreign key constraints referencing regular tables, migrate the data using a process like exporting and reimporting since you generally cannot alter a table directly into memory optimized, and thoroughly test application compatibility since memory optimized tables have some T-SQL syntax restrictions.
-- Create the new memory optimized table first
CREATE TABLE Orders_New (
OrderId INT PRIMARY KEY NONCLUSTERED,
CustomerId INT,
Amount DECIMAL(10,2)
) WITH (MEMORY_OPTIMIZED = ON);
-- Then migrate the data
INSERT INTO Orders_New SELECT * FROM Orders;Real-world example
A team migrating a busy orders table to memory optimized storage carefully reviews it for unsupported foreign key constraints first, adjusts their schema accordingly, and thoroughly tests their application before switching over in production.
Likely follow-ups
- What data types are not supported in memory optimized tables?
- How do you handle foreign key relationships when migrating to memory optimized tables?
Related topics