Instant File Initialization – Killer Feature for SQL Server

When SQL Server reserves new space on a disk, it initializes the space with zeros. This behavior can be switched off thereby reducing the execution time of some operations and the load on the disk subsystem.

Disk space reservation without initialization is called Instant File Initialization. This feature is not widely known, although its use has become possible starting with SQL Server 2005.

The benefits of the Instant File Initialization are the following:

1. Accelerating the creation of a new database.

2. Reducing delays and time required to expand data files.

3. Reducing the start time of SQL Server due to faster tempdb initialization.

4. Reducing time for restoring from a backup, because SQL Server reserves space for files before restoration and then transfers the information from the backup into the files.

It is important to note that Instant File Initialization works only for data files (MDF and NDF). Log files (LDF) are always zero-initialized.

How to use Instant File Initialization?

The option may be enabled fairly simply. Open SQL Server Configuration Manager to see the name of SQL Server instance.

SQL Server instance

After that, in the Local Security Policy window, navigate to User Rights Assignment and select Perform volume maintenance tasks.

Local Security Policy

On the Local Security Setting tab, add the server instance, as shown in the following picture.

Local Security Setting

SQL Server instance verifies the rights required for working with Instant File Initialization only once – during the launch. That is why you need to restart SQL Server to apply the configuration.

Test Cases

First, let’s examine whether Instant File Initialization is enabled?

If it is disabled, upon execution of the query:

in SQL Server log, you will see that data files are filled with zeros:

Option disabled

But if Instant File Initialization is enabled, then only the log file is filled with zeros:

Option enabled

Alternatively, you can use the following script:

In case you need to temporarily disable Instant File Initialization, you can enable trace flag 1806. However, as practice shows, using this functionality greatly saves time and reduces disk load.

Here are a couple of test cases and time spent executing them with and without Instant File Initialization:

Summary

The use of Instant File Initialization is a terrific way to reduce downtime during failure recovery. It won’t take you much time to initialize files for filling them with zeros before the recovery. So keep in mind that there is such useful thing as Instant File Initialization.

P.S: In SQL Server 2016, you can easily turn on this option upon installing a new instance.

SQL Server 2016 installation

Leave a Comment