다음을 통해 공유


SQL 2016 - It Just Runs Faster: -T1117 and -T1118 changes for TEMPDB and user databases

Configuration of TEMPDB is often critical to scalability and throughput of SQL Server applications. The following link (https://support.microsoft.com/en-us/kb/2964518) outlines how to configure SQL Server 2014 and 2012 for optimal scalability and performance.

 

A SQL Server 2016 primary goal was 'It Just Works.' Out of the box a customer should not have to engage in such documentation and tuning exercises. Whenever possible SQL Server should just work and provide the intended scalability and performance outcomes.

 

TEMPDB

One of these changes is TEMPDB always assumes -T1117 and -T1118 behavior.

 

  • -T1117 - When growing a data file grow all files at the same time so they remain the same size, reducing allocation contention points.
  • -T1118 - When doing allocations for user tables always allocate full extents. Reducing contention of mixed extent allocations

 

In summary, SQL Server 2016 no longer requires one to turn on TF 1117 or 1118.

 

User Database

For User Databases, trace flags 1117 and 1118 have been replaced with new extensions in ALTER DATABASE commands. Use the ALTER DATABASE syntax to enable or disable the desired trace flag behavior at a database level.

 

-- Trace Flag 1118

  1. Trace flag 1118 for user databases is replaced by a new ALTER DATABASE setting - MIXED_PAGE_ALLOCATION.
  2. Default value of the MIXED_PAGE_ALLOCATION is OFF meaning allocations in the database will use uniform extents.
  3. The setting is opposite in behavior of the trace flag (i.e. TF 1118 OFF and MIXED_PAGE_ALLOCATION ON provide the same behavior and vice-versa).

 

Syntax:

ALTER DATABASE <dbname> SET MIXED_PAGE_ALLOCATION { ON | OFF }

For more information see https://msdn.microsoft.com/en-US/library/bb522682.aspx

 

Example:

--Default value is OFF so all allocations in AdventureWorks will use uniform extents. To disable and use mixed extents turn the setting to on.

 ALTER DATABASE AdventureWorks SET MIXED_PAGE_ALLOCATION ON;

 

Catalog changes:

A new column is_mixed_page_allocation_on is added to DMV sys.databases that shows which allocation type (uniform or mixed) is being used. For more information see, https://msdn.microsoft.com/en-us/library/ms178534.aspx

 

-- Trace Flag 1117

  1. Trace flag 1117 for user databases is replaced by a new ALTER DATABASE setting at the FILEGROUP level.
  2. Default value is to grow a single file - AUTOGROW_SINGLE_FILE (which is same as the trace flag not being enabled).
  3. This setting is at the file group level (not the entire database level).
  4. For a database that contains many files, the AUTOGROW_ALL_FILES setting has to be to enabled for each filegroup.

 

Syntax:

ALTER DATABASE <dbname> MODIFY FILEGROUP <filegroup> { AUTOGROW_ALL_FILES | AUTOGROW_SINGLE_FILE } 

For more information see https://msdn.microsoft.com/en-us/library/bb522469.aspx

 

Example:

--Default value is AUTOGROW_SINGLE_FILE for all files in all filegroups. To enable growth for all files in a file group in AdventureWorks run the following ALTER DATABASE statement.

ALTER DATABASE AdventureWorks MODIFY FILEGROUP [PRIMARY] AUTOGROW_ALL_FILES;

 

Catalog changes:

A new column is_autogrow_all_files is added to DMV sys.filegroups that shows which growth setting is being used. For more information see, https://msdn.microsoft.com/en-us/library/ms187782.aspx

 

 

'It Just Runs Faster' - Out of the box SQL Server 2016 enables the -T1117 and -T1118 behavior for TEMPDB providing better scalability and performance.

 

Ajay Jagannathan - SQL Server Principal Program Manager

Bob Dorr - Principal SQL Server Escalation Engineer

Comments

  • Anonymous
    April 22, 2016
    Awesome! Thanks for making this important change, especially with your selection of what the defaults are!
  • Anonymous
    July 23, 2017
    Thanks for sharing this.
  • Anonymous
    February 12, 2019
    For the sake of completeness - you can find out, if the MIXED_PAGE_ALLOCATION (replacement for trace flag 1118) is on or off by executing:SELECT d.name, d.is_mixed_page_allocation_on FROM sys.databases d
  • Anonymous
    June 04, 2019
    Thanks!