Amazon RDS for SQL Server now supports Microsoft SQL Server 2019 for Express, Web, Standard, and Enterprise Editions. You can use SQL Server 2019 features such as Accelerated Database Recovery, Intelligent Query Processing, Intelligent Performance, Monitoring improvements, and Resumable Online Index creations.
The purpose of this post is to:
- Summarize the new features in SQL Server 2019 that are supported in Amazon RDS for SQL Server
- Explain when and how the compatibility level of a database is set
- Describe changes to
- Review a few caveats with respect to some of the new features
Amazon RDS for SQL Server 2019 supports the following new features:
- Accelerated database recovery (ADR) improves database availability by reducing crash recovery time. ADR also allows for instantaneous transaction rollback and aggressive transaction log truncation, even in the presence of active long-running transactions.
- Intelligent query processing (IQP) features such as:
- Row mode memory grant feedback to automatically correct excessive memory grants based on real execution statistics. Row mode memory grant feedback is an extension to the batch mode memory grant feedback feature in previous version of SQL Server . This feature fine-tunes the memory grant sizes for both batch and row mode operator.
- Batch mode runs on rowstore, without requiring column store indexes.
- Scalar User Defined Functions (UDF) Inlining to automatically transform UDFs into scalar expressions or scalar subqueries.
- Table variable deferred compilation, to defer the compilation of a statement that references a table variable until the first actual use of the statement, resulting in actual cardinality use.
- Approximate counts with
APPROX_COUNT_DISTINCTto return the approximate number of unique non-null values in a group without having to scan the entire table.
- Interleaved implementation for multi-statement table-valued functions to pause the optimization until the applicable subtree runs and accurate cardinality estimates are received.
tempdbmetadata improves scalability of
tempdb-heavyworkloads by moving system tables managing temporary table metadata into latch-free, non-durable, memory-optimized tables.
- Intelligent Performance features such as:
OPTIMIZE_FOR_SEQUENTIAL_KEYfor index creation, which improves the throughput for high-concurrency inserts into an index.
- Forcing fast forward and static cursors provides Query Store plan forcing support for fast forward and static cursors.
- Indirect checkpoint scalability improvements to help DML-heavy workloads.
- Reduced recompilations for workloads running DML on temporary tables created by an outer scope batch.
- Concurrent Page Free Space (PFS) updates by using a shared latch instead of an exclusive latch.
- Scheduler worker migration enables the migration of long-running tasks across schedulers on the same NUMA node to provide balanced CPU usage.
- Monitoring improvements such as:
- A new wait type,
WAIT_ON_SYNC_STATISTICS_REFRESHshows accumulated instance-level time spent on synchronous statistics refresh operations.
LIGHTWEIGHT_QUERY_PROFILINGto reduce the overhead of capturing performance data.
dm_exec_requeststo show “
SELECT (STATMAN)” for tasks waiting on a synchronous statistics update.
- Dynamic Management Function (DMF)
dm_exec_query_plan_statsreturns the last known actual query plan when
LAST_QUERY_PLAN_STATSdatabase configuration is enabled.
dm_db_page_inforeturns information about a database page.
- A new wait type,
- Mission-critical security features such as:
- Data Discovery & Classification to facilitate classifying and labeling columns basing on their data content.
- SQL Server Audit enhancements to view the new
data_sensitivity_informationcolumn in the Audit Log.
- Transparent Data Encryption (TDE) is now also available on Standard Edition.
- The data truncation error message defaults to include table and column names, and the truncated value.
Prior to SQL Server 2019, only resumable online index rebuild was supported. Resumable online index creations are also now supported. For more details, review the Guidelines for online index operations.
Provisioning a SQL Server 2019 DB instance
You can provision a SQL Server 2019 DB instance on Amazon RDS for SQL Server two different ways:
- Create a new RDS DB instance with the engine version = 15.00
- Upgrade an existing DB instance to engine version = 15.00
Amazon RDS for SQL Server supports upgrading directly to SQL Server 2019 from all supported versions. The oldest supported engine version is SQL Server 2012 (engine version 11.00).
We highly recommend testing database workloads on the new engine version prior to upgrading the DB instances. Amazon RDS for SQL Server makes this easy to do. Simply take a snapshot of the DB instance, restore the snapshot as a test DB instance, and upgrade the test DB instance to the new engine version. When the testing is complete, you can stop the test DB instance. For more information about testing and upgrading to new major versions, see Best practices for upgrading SQL Server 2008 R2 to SQL Server 2016 on Amazon RDS for SQL Server.
You can provision a SQL Server 2019 DB instance on Amazon RDS for SQL Server by using the AWS Management Console, AWS Command Line Interface (AWS CLI), AWS SDK, or AWS CloudFormation. While provisioning the DB instance, the engine version needs to be set to 15.00.
The compatibility level defines the Transact SQL (T-SQL) and query processing behavior in SQL Server. For more information, see ALTER DATABASE (Transact-SQL) Compatibility Level. The compatibility level is set at the database level and the native compatibility level of a newly created database on SQL Server 2019 is 150.
Irrespective of the provisioning method (creating a new DB instance or upgrading an existing DB instance), a newly created database on an RDS SQL Server 2019 DB instance has a compatibility level of 150 by default. On an upgraded RDS SQL Server 2019 DB instance, existing databases that were created on older engine versions prior to the engine version upgrade remain on the older compatibility level. For example, if an RDS SQL Server 2017 DB instance was upgraded to SQL Server 2019, prior to the upgrade, databases created on SQL Server 2017 had a compatibility level of 140. These databases continue to have a compatibility level of 140 even after the upgrade. However, after the upgrade, you can change the compatibility level using the
ALTER DATABASE T-SQL command:
alter database <db_name> set compatibility_level=150
SQL Server Management Studio (SSMS) provides an option to change the compatibility mode via the SSMS graphical user interface (GUI). This requires elevated privileges that aren’t available in Amazon RDS, so you can’t change the compatibility level using the SSMS GUI. Instead, use the T-SQL command to change the compatibility level.
Changes to tempdb
In Amazon RDS for SQL Server, starting with SQL Server 2019, the number of
tempdb data files created by default has changed. Prior to SQL Server 2019, an RDS SQL Server instance had one
tempdb data file across all editions and instance sizes. With SQL Server 2019, a newly created RDS SQL Server 2019 DB instance uses the following mapping for deciding how many
tempdb data files get created.
|Edition||Instance Class Size||Number of TempDB Data Files|
|Enterprise/Standard and Web||db.*.xlarge and below||Number of vCPUs|
|Enterprise/Standard and Web||db.*.2xlarge and above||8|
The number of
tempdb data files are decided during the creation of the DB instance. Post-creation, scaling a DB instance up or down doesn’t change the number of
tempdb data files. For example, a newly created Standard Edition db.m5.xlarge DB instance has four
tempdb datafiles. Scaling the instance to a db.m5.2xlarge doesn’t increase the number of
tempdb files to eight.
Using the new Amazon RDS for SQL Server features
You can enable and use most of the new features as described in the SQL Server documentation, but there are a few exceptions.
Multi-AZ deployments in Amazon RDS for SQL Server 2019 use one of two modes for synchronous replication: Always On or database mirroring, depending on the edition and upgrade path. Keep in mind the following:
- A newly created Multi-AZ RDS SQL Server 2019 Enterprise Edition (EE) DB instance uses Always On.
- Enabling Multi-AZ on a newly created Single-AZ RDS SQL Server 2019 EE DB instance uses Always On.
- Enabling Multi-AZ on a Single-AZ RDS SQL Server 2019 EE DB instance that was upgraded from any older engine version or edition uses Always On.
- A Multi-AZ DB instance upgraded from an older engine version to SQL Server 2019 uses the same mode it used on the older engine version.
- All Standard Edition DB instances use database mirroring.
To check if a Multi-AZ DB instance is using Always On or database mirroring, on the Amazon RDS console, choose the database and navigate to its Configuration tab.
On the Configuration tab, look for Multi AZ. For a Multi-AZ DB instance using Always On, the setting shows as Yes (Always On). For a DB Multi-AZ instance using database mirroring only, the setting shows as just Yes.
To check using the AWS CLI or the AWS SDK, look for the
ListenerEndpoint. Multi-AZ DB instances using database mirroring only have one endpoint. An additional
ListenerEndpoint exists for Multi-AZ DB instances using Always On.
You can change a Multi-AZ RDS SQL Server 2019 EE DB instance using database mirroring to use Always On by converting the DB instance to Single-AZ and then re-enabling Multi-AZ.
Accelerated database recovery
ADR is a SQL database engine feature that greatly improves database availability, especially in the presence of long running transactions, by redesigning the SQL database engine recovery. ADR achieves fast database recovery by versioning database modifications and only undoing logical operations, which are limited and can be undone almost instantly. Any transactions that were active at the time of a crash are marked as stopped and therefore concurrent user queries can ignore any versions generated by these transactions. For more information, see Accelerated database recovery.
In Amazon RDS for SQL Server, ADR is fully supported on Single-AZ instances. On a Multi-AZ instances, ADR is supported on instances using Always On and is not supported on instances using database mirroring.
As indicated in this bugfix, ADR is incompatible with database mirroring and trying to enable ADR on a mirrored database results in an error:
Msg 1484, Level 16, State 1, Line LineNumber
Database Mirroring cannot be set for database 'ADR_Mirroring' because the database has Accelerated Database Recovery enabled or there are still versions in the Persisted Version Store. If Accelerated Database Recovery is disabled, please run sys.sp_persistent_version_cleanup '<DatabaseName>' to clean up previous versions.
On a Multi-AZ DB instance using database mirroring, enabling ADR on a newly created database results in Amazon RDS automation disabling ADR and enabling database mirroring. When enabling Multi-AZ on a DB instance wherein the mode is database mirroring, if ADR enabled databases are found, enabling Multi-AZ fails and the following notification appears:
Unable to convert the DB instance to Multi-AZ: The database(s) ‘<db_name>’ prevented the conversion because they have Accelerated Database Recovery (ADR) enabled. Disable ADR for these databases and try again.
Intelligent query processing
All IQP features in SQL Server 2019 are supported in Amazon RDS for SQL Server. Apart from the Approximate Count Distinct feature, you need to enable all the IQP features at the database level using the following command:
alter database scoped configuration set <feature_name>=on
You can also enable some of these features on
tempdb, and the Amazon RDS primary user has the permissions to do so.
On Multi-AZ DB instances, enabling these features on
tempdb needs to be done on the primary and secondary. This can be achieved in two ways:
- Enable the feature on the primary, reboot the DB instance with failover, and enable the feature on the new primary
- Convert the Multi-AZ DB instance to Single-AZ, enable the feature, and convert the DB instance to Multi-AZ
Amazon RDS for SQL Server doesn’t support persistent memory (PMEM) devices and SQL Server native database snapshots. So, the enhancement to Hybrid Buffer Pool to use PMEM devices and In-Memory OLTP support for SQL Server native database snapshots are not supported.
tempdb metadata feature is supported in Amazon RDS for SQL Server. You can enable this feature by running the
alter server configuration command. However, the Amazon RDS primary user doesn’t have access to run this command on an RDS SQL Server DB instance. Instead, you can set the parameter “Memory optimized
tempdb Metadata” in the Amazon RDS parameter group. After applying the parameter group with the modified parameter to the DB instance, the feature is enabled on the DB instance.
As part of Intelligent Performance, SQL Server 2019 brings some enhancements to Resource Governance. Given that Amazon RDS for SQL Server doesn’t support SQL Server’s Resource Governor feature, these enhancements are not supported. All other Intelligent Performance features like concurrent PFS updates, scheduler worker migration, and more, are supported in Amazon RDS for SQL Server.
Data Discovery & Classification introduces a new tool built into SSMS for discovering, classifying, labeling, and reporting sensitive data in databases. For more information, see SQL Data Discovery and Classification. Using SSMS version 17.5 and above, Data Discovery & Classification is achievable on Amazon RDS for SQL Server. You can also add data sensitivity labeling using the ADD SENSITIVITY CLASSIFICATION clause, and the Amazon RDS primary user has the necessary permissions to run this command.
The data sensitivity information has been added to the SQL Server Audit file record under the new field
data_sensitivity_information. You can enable SQL Server auditing in Amazon RDS for SQL Server using options groups. After the SQL Server Audit is enabled on the DB instance and audit specifications are created, you can read the Audit files on the DB instance using the function msdb.dbo.rds_fn_get_audit_file. This function also returns the new field
You can read the audit files as long as they are on the disk. To change how long the audit files should be persisted on the disk, you can configure the parameter RETENTION_TIME while setting up the SQL Server Audit option.
Amazon RDS for SQL Server now supports TDE for SQL Server Standard Edition. TDE needs be enabled on the DB instance using option groups. For more information about enabling TDE, see Support for Transparent Data Encryption in SQL Server.
In this post, we listed some of the new and exciting features of SQL Server 2019 that are supported in Amazon RDS for SQL Server, along with brief descriptions of the features. We called out cases where the features differ slightly, provided instructions on how to enable the features, and advised on any prerequisites they might have. A major engine version release like SQL Server 2019 brings significant changes to the engine—some visible and others not. We highly recommend testing database workloads using the Amazon RDS easy clone mechanisms as described in this post before upgrading to this new engine version.
About the Author
Prashant Bondada is a Senior Database Engineer at Amazon Web Services. He works on the RDS team, focusing on commercial database engines, SQL Server and Oracle.
Sudarshan Roy is a Senior Database Specialist Cloud Solution Architect with the AWS Database Services Organization (DBSO), Customer Advisory Team (CAT). He has led large scale Database Migration & Modernization engagements for Enterprise Customers to move their on-premises database environment to Multi Cloud based database solutions.