What the heck is Accelerated Database Recovery?
Tags: sql, sqlserver, recovery
Published: 2020-01-01 20:54:47

---
title: What the heck is Accelerated Database Recovery?
published: true
date: 2019-10-21 14:00:15 UTC
tags: SQL, sqlserver, recovery
canonical_url: https://am2.co/2019/10/what-the-heck-is-accelerated-database-recovery/
---

[![](http://am2.co/wp-content/uploads/eggy-febryano-de_A1VmNapQ-unsplash-1024x768.jpg)](https://www.youtube.com/watch?v=54I5RU-RNhQ)<figcaption id="caption-attachment-2229">The intersection of Crash Recovery Boulevard and Version Store Avenue is now known as ADR Square.</figcaption>

  
Last week, I wrote about the [SQL Server Version Store](https://am2.co/2019/10/what-the-heck-is-the-sql-server-version-store/). The week before, I looked at [crash recovery](https://am2.co/2019/10/recovery-of-database-is-0-complete-approximately-1000000-seconds-remain/). Let’s look next at a new feature in SQL Server 2019, where these two features intersect: Accelerated Database Recovery.
## What is it?

Accelerated Database Recovery(ADR) is a new feature intended to speed up the recovery process, which could be very slow, particularly when there are long-running, large transactions. ADR is not just for recovery after a crash, but also helps in other scenarios where the transaction log needs to be recovered–including Availability Group secondary redo and Failover Cluster Instance failovers.

ADR is not enabled by default. You can check to see if it is enabled on any databases with this query:

```sql
SELECT [name], 
       is_accelerated_database_recovery_on 
FROM sys.databases;
```

If you want to enable ADR on a database, it’s controlled by a database-scoped configuration:

```sql
ALTER DATABASE rhotacism 
    SET ACCELERATED_DATABASE_RECOVERY = ON;
```

As of today, this setting isn’t exposed in any UI in SSMS or Azure Data Studio–but SQL Server 2019 isn’t officially released yet, so it’s certainly possible this will make its way into the UI at some point.

## How does it work?

Aaron Bertrand ([blog](http://sqlblog.org)|[twitter](https://twitter.com/AaronBertrand)) recently provided [a detailed look into ADR](https://www.mssqltips.com/sqlservertip/5971/accelerated-database-recovery-in-sql-server-2019/). He does a great job at explaining the internals, and I can’t do a better job. [Go read his post](https://www.mssqltips.com/sqlservertip/5971/accelerated-database-recovery-in-sql-server-2019/).

I mentioned that ADR is the intersection between crash recovery & version store. Let’s look specifically at that aspect of ADR. One of the key changes that makes ADR possible is a persisted version store. This version store is similar to the one described in [my last post](https://am2.co/2019/10/what-the-heck-is-the-sql-server-version-store/), except instead of being in tempdb (and being…temporary), it’s persisted within the database itself. By keeping this persistent version store, SQL Server has ready access to the prior versions of the row, allowing it to more quickly “undo” to the prior row, rather than having to reconstruct it from the transaction log. And just like the tempdb version store, there is an asynchronous cleanup process to come through and make sure that unneeded versions are cleaned up to prevent database bloat.

By removing the ephemeral nature of the version store, the persisted version store is guaranteed to be available following a reboot/crash/failover, and also syncs across an AG to the secondary node (_everything_ inside the database is synched across the AG). Recall that RCSI uses the version store to create a consistent committed copy of the data while it is being concurrently updated; ADR uses the persisted version store to create a consistent copy of the data to revert to when rolling back uncommitted changes.

I haven’t yet played much with ADR, but I’m particularly excited to look at how it affects redo on an Availability Group secondary during failover. AG Failovers are already pretty fast–but there _is_ a momentary outage while SQL Server transitions primary from one node to the other, and reconciles transactions by completing redo on committed transactions and undo on uncommitted transactions. ADR should make that failover _even faster_ by reducing the time needed for redo/undo. Simply by enabling ADR, you may be able to improve your uptime by making that recovery faster–just remember to test first.

The post [What the heck is Accelerated Database Recovery?](https://am2.co/2019/10/what-the-heck-is-accelerated-database-recovery/) appeared first on [Andy M Mallon - AM²](https://am2.co).