Hard disk with data file blocks allocated at once next to a database and a stopwatch, representing SQL Server Instant File Initialization

SQL Server Instant File Initialization: What It Speeds Up, How to Enable It and How to Verify It

How Instant File Initialization removes zeroing from SQL Server data file creation, growth and restores, what it doesn’t cover, the security trade-off, and how to enable and verify it without losing it to Group Policy.

September 15, 2021

When SQL Server creates a new data file or grows an existing one, by default it first fills the entire allocated space with zeros. For a growth of a few megabytes, nobody notices. But during a restore of several hundred gigabytes, a large autogrowth triggered at midnight or a database rebuilt during an outage, the server can spend minutes doing nothing but writing zeros to disk while work waits.

Instant File Initialization (IFI) is the Windows feature that removes this zeroing step for data files. This guide explains exactly what IFI speeds up and what it doesn’t, the security trade-off, how to enable it and how to verify that it actually works.

SQL Server Performance Consulting

Why do restores and file growths take so long?

Aryasoft reviews Instant File Initialization, autogrowth, disk layout and service account rights together, and measurably shortens your restore times and RTO.

Get Support

What Is Instant File Initialization?

When Windows allocates new space to a file, that space may still contain remnants of previously deleted data. To prevent those remnants from being read, SQL Server by default fills newly allocated space with zeros. This is called zeroing, and how long it takes depends directly on the file size and the write speed of the storage.

When the SQL Server service account has the Windows Perform volume maintenance tasks right (the SE_MANAGE_VOLUME_NAME privilege), SQL Server skips this step for data files. The space is allocated instantly, and the old disk content is only overwritten as new data is written.

A quick calculation shows the difference: on storage that writes 500 MB per second, zeroing a 100 GB data file takes about 200 seconds, and zeroing a 1 TB file takes more than half an hour. With IFI enabled, that drops to a few seconds.

What IFI Speeds Up

Zeroing happens for data files in the following operations, and IFI makes a difference in all of them:

  • Creating a database: databases created with a large initial size are ready immediately.
  • Adding files to an existing database: adding a new data file or filegroup no longer causes a wait.
  • Growing a file: both manual growths and autogrowth events. The session that triggers an autogrowth waits until the growth completes; without IFI, a large growth increment shows up as sudden timeouts in the application.
  • Restore: SQL Server creates the target files before it starts copying data. Without IFI, restoring a large database begins with a long zeroing phase before a single page of data is read. In a disaster, that directly lengthens your RTO.
  • TempDB: TempDB is recreated at every service start. Large, pre-sized TempDB data files come online much faster with IFI.

What IFI Doesn’t Speed Up

  • Transaction log files: log files must be zeroed because of how the transaction log is structured. Creating and growing a log file, and creating it during a restore, doesn’t benefit from IFI.
  • Databases encrypted with TDE: when Transparent Data Encryption is enabled for a database, its data files can’t benefit from IFI either.
  • Slow queries: IFI doesn’t change everyday query performance; it only removes the wait at the moment space is allocated.

Note

In SQL Server 2022 and later, transaction log growth events of up to 64 MB can also benefit from instant initialization, and new databases default to a 64 MB log autogrowth. Larger log growths are still zeroed, so sizing the log file correctly from the start and choosing the growth increment deliberately still matters. See our autogrowth guide for details.

The Security Trade-off

Because newly allocated space isn’t zeroed when IFI is enabled, previously deleted content on the disk physically remains inside the data file until new data is written over that area. In theory, someone with direct access to the data file could read those remnants.

In practice, the risk is limited by a few conditions:

  • Only the SQL Server service account and administrators should have access to the folders that hold data files.
  • Detached data files and backup files should also be stored with restrictive permissions.
  • The server should be in a physically and logically secure environment.

When these conditions are met, the performance gain outweighs the risk, and IFI is the recommended standard setting for production servers. In high-security environments where disclosure of deleted content is unacceptable, IFI can be left disabled, or TDE can be used. For the broader picture of file and folder permissions, see our SQL Server security hardening guide.

How to Check Whether IFI Is Enabled

In current versions (SQL Server 2016 SP1 and later), the easiest way is the DMV that returns service information:

SELECT servicename,
       service_account,
       instant_file_initialization_enabled   -- Y = enabled, N = disabled
FROM sys.dm_server_services
WHERE servicename LIKE N'SQL Server (%';

SQL Server also writes the same information to the error log at every startup:

EXEC sys.xp_readerrorlog 0, 1, N'Database Instant File Initialization';

You’ll see either “Database Instant File Initialization: enabled” or “disabled”.

How to Enable Instant File Initialization

During installation

In SQL Server 2016 and later, the Server Configuration page of the setup wizard has a Grant Perform Volume Maintenance Task privilege to SQL Server Database Engine Service option. Ticking it is the cleanest approach for new installations. For a command-line installation, the /SQLSVCINSTANTFILEINIT="True" parameter does the same.

On an existing server

1. Find the service account. The service_account column of the DMV query above, or the Log On As column in the SQL Server Services view of SQL Server Configuration Manager, shows which account the Database Engine service runs as. For a default instance installed with a virtual account, this is NT Service\MSSQLSERVER; for a named instance, NT Service\MSSQL$InstanceName.

SQL Server Configuration Manager showing SQL Server Services and the service account in the Log On As column

2. Grant the right.

  1. Open secpol.msc (Local Security Policy) or gpedit.msc as an administrator.
  2. Go to Computer Configuration › Windows Settings › Security Settings › Local Policies › User Rights Assignment.
  3. Open the Perform volume maintenance tasks policy and use Add User or Group to add the service account from step 1. For a virtual account, make sure the location is the local computer.

Adding the SQL Server service account to the Perform volume maintenance tasks right in Local Group Policy Editor

3. Restart the SQL Server service. The privilege is read when the service starts. Plan the restart in a maintenance window; in an Always On availability group or failover cluster, grant the right on every node and restart the nodes one at a time.

Warning

If the Perform volume maintenance tasks right is defined in a domain Group Policy, the domain policy overwrites the local setting at the next policy refresh, and your change silently disappears. In domain environments, check with gpresult /h report.html whether a GPO controls this right, and have the service account added to that GPO. Repeat the check when the server moves to another OU or is replaced during a migration.

Check the right from the command line

# Export the local security policy and look for the privilege
secedit /export /cfg "$env:TEMP\secpol.cfg" /areas USER_RIGHTS | Out-Null
Select-String -Path "$env:TEMP\secpol.cfg" -Pattern 'SeManageVolumePrivilege'

The output lists accounts as SIDs (*S-1-5-80-... for virtual service accounts). Granting the right through the local Administrators group also enables IFI, but making the service account an administrator violates least privilege; grant the right to the service account directly.

Testing That It Actually Works

Even when the DMV says “Y”, you can confirm that zeroing is really skipped by having trace flags 3004 and 3605 write file-zeroing messages to the error log. Run this test in a test or maintenance environment, not in production:

DBCC TRACEON (3004, 3605, -1);   -- write zeroing operations to the error log

CREATE DATABASE IFI_Test
ON (NAME = IFI_Test_data, FILENAME = N'D:\SQLData\IFI_Test.mdf', SIZE = 1GB)
LOG ON (NAME = IFI_Test_log, FILENAME = N'L:\SQLLog\IFI_Test.ldf', SIZE = 64MB);

EXEC sys.xp_readerrorlog 0, 1, N'Zeroing';

DBCC TRACEOFF (3004, 3605, -1);
DROP DATABASE IFI_Test;

With IFI enabled, the error log shows a “Zeroing …” line only for the .ldf file. If you also see one for the .mdf, IFI isn’t working: check the service account, the restart and the GPO. Remember to change the file paths to match your environment.

Virtual Machines and the Cloud

IFI works on virtual machines exactly as it does on physical servers and delivers the same benefit; on shared, relatively slow storage the gain is even more noticeable. Microsoft’s best practices checklist for SQL Server on Azure virtual machines also recommends enabling IFI for data files. In Azure SQL Database and Azure SQL Managed Instance, this setting is managed by the platform.

Instant File Initialization Checklist

  • instant_file_initialization_enabled = 'Y' in sys.dm_server_services.
  • The right is granted to the service account directly; the service account isn’t a local administrator.
  • In a domain, the right is defined in the GPO that controls the server’s OU.
  • Every node in Always On and cluster environments has been checked.
  • Permissions on data, log and backup folders are restricted.
  • Log files are sized correctly from the start, with a deliberately chosen growth increment.
  • The IFI option is part of your new server build checklist.
It’s a Windows feature that lets SQL Server skip filling allocated space with zeros when it creates or grows data files. It’s enabled when the service account has the Perform volume maintenance tasks right.
Generally no; transaction log files are always zeroed. In SQL Server 2022 and later, log growth events of up to 64 MB are the exception.
Yes. The privilege is read when the service starts, so the SQL Server service must be restarted.
Run SELECT servicename, instant_file_initialization_enabled FROM sys.dm_server_services. Y means enabled, N means disabled. The “Database Instant File Initialization” line in the error log gives the same information.
No. When Transparent Data Encryption is enabled for a database, its data files can’t benefit from IFI and are zeroed.

SQL Server Performance Consulting

Cut your restore and file growth times

Aryasoft’s senior DBA team configures Instant File Initialization, Lock Pages in Memory, autogrowth and disk layout through the right policy on every node, and verifies the result after the restart.

4.7/5