Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Introducing Microsoft SQL Server 2019

You're reading from   Introducing Microsoft SQL Server 2019 Reliability, scalability, and security both on premises and in the cloud

Arrow left icon
Product type Paperback
Published in Apr 2020
Publisher Packt
ISBN-13 9781838826215
Length 488 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (8):
Arrow left icon
Allan Hirt Allan Hirt
Author Profile Icon Allan Hirt
Allan Hirt
Dustin Ryan Dustin Ryan
Author Profile Icon Dustin Ryan
Dustin Ryan
Mitchell Pearson Mitchell Pearson
Author Profile Icon Mitchell Pearson
Mitchell Pearson
Kellyn Gorman Kellyn Gorman
Author Profile Icon Kellyn Gorman
Kellyn Gorman
Dave Noderer Dave Noderer
Author Profile Icon Dave Noderer
Dave Noderer
Buck Woody Buck Woody
Author Profile Icon Buck Woody
Buck Woody
Arun Sirpal Arun Sirpal
Author Profile Icon Arun Sirpal
Arun Sirpal
James Rowland-Jones James Rowland-Jones
Author Profile Icon James Rowland-Jones
James Rowland-Jones
+4 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Optimizing for performance, scalability and real‑time insights 2. Enterprise Security FREE CHAPTER 3. High Availability and Disaster Recovery 4. Hybrid Features – SQL Server and Microsoft Azure 5. SQL Server 2019 on Linux 6. SQL Server 2019 in Containers and Kubernetes 7. Data Virtualization 8. Machine Learning Services Extensibility Framework 9. SQL Server 2019 Big Data Clusters 10. Enhancing the Developer Experience 11. Data Warehousing 12. Analysis Services 13. Power BI Report Server 14. Modernization to the Azure Cloud

Planning data migration to memory-optimized tables

Microsoft SQL Server Management Studio (SSMS) contains tools to help analyze and migrate tables to memory-optimized storage.

When you right-click on a database in SSMS and click on Reports | Standard Reports | Transaction Performance Analysis Overview, a four-quadrant report of all tables in the database will be made:

Figure 1.3: Choosing Transaction Performance Analysis
Figure 1.3: Choosing Transaction Performance Analysis

The report will look at each table and place it on the chart to show the ease of migration versus the expected gain by migrating the table to be memory-optimized:

Figure 1.4: Recommended Tables Based on Usage
Figure 1.4: Recommended Tables Based on Usage

Once you have identified tables that might benefit, you can right-click on individual tables and run the Memory Optimization Advisor:

Figure 1.5: Selecting the Memory Optimization Advisor
Figure 1.5: Selecting the Memory Optimization Advisor

The Table Memory Optimization Advisor is a "wizard" style of user interface that will step you through the configurations:

Figure 1.6: The Table Memory Optimization Advisor dialogue
Figure 1.6: The Table Memory Optimization Advisor dialogue

The wizard will take you through a checklist with any failed issues:

Figure 1.7: Memory Optimization Checklist
Figure 1.7: Memory Optimization Checklist

The warnings dialogue will flag up other important issues.

Figure 1.8: Memory Optimization Warnings
Figure 1.8: Memory Optimization Warnings

Next enter file names and check paths in the migration option dialogue.

Figure 1.9: Review Optimization options
Figure 1.9: Review Optimization options

The wizard will detect the primary keys and populates the list of columns based on the primary key metadata. To migrate to a durable memory-optimized table, a primary key needs to be created. If there is no primary key and the table is being migrated to a non-durable table, the wizard will not show this screen.

Figure 1.10: Review Primary Key Conversion
Figure 1.10: Review Primary Key Conversion

By clicking Script you can generate a Transact-SQL script in the summary screen.

Figure 1.11: Verify Migration Actions Summary Screen
Figure 1.11: Verify Migration Actions Summary Screen

The wizard will the display a report as the table migrates.

Figure 1.12: Migration progress report
Figure 1.12: Migration progress report

Memory-optimized tables are a great feature, but you will need to plan carefully to make sure you get the performance and transactional reliability you require.

You can create a new database specifying memory-optimized, or alter an existing database to handle memory-optimized data. In either case, a filegroup for containing the memory-optimized data must be created.

In the following sample, we will create a memory-optimized database using SQL script:

-- Create Memory-Optimized Database
USE MASTER;
GO
CREATE DATABASE MemOptDB
  ON (Name = MemOptDB_Data, FileName = 'c:\sqldata\memoptdb_data.mdf', size = 10 mb, maxsize = 20 mb, filegrowth = 5 mb)
  LOG ON (Name = MemOptDB_Log, FileName = 'c:\sqldata\memoptdb_log.ldf', size = 2 mb, maxsize = 10 mb, filegrowth = 1 mb);
GO
-- Must declare a memory-optimized filegroup
ALTER DATABASE MemOptDB 
  ADD FILEGROUP MemOptDB_FG contains MEMORY_OPTIMIZED_DATA;
ALTER DATABASE MemOptDB 
  ADD FILE (Name = 'MemOptDB_MOFG', FileName = 'c:\sqldata\memoptdb_mofg')
  TO FILEGROUP MemOptDB_FG;
ALTER DATABASE MemOptDB
  SET MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT = ON;
GO

You can also make a memory-optimized database by using SQL Server Management Studio and adding a memory-optimized filegroup:

Figure 1.13: The new database dialogue window
Figure 1.13: The new database dialogue window
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image