Minimizing TempDB Contention in SQL Server
By Tom Nonmacher
As a database administrator, one of the challenges you may encounter is TempDB contention in SQL Server. This can notably impact the performance of your databases. TempDB contention happens when multiple tasks are trying to create or delete temporary objects at the same time. In this post, we'll discuss ways to minimize TempDB contention, focusing on technologies from SQL Server 2016, SQL Server 2017, MySQL 5.7, DB2 11.1, and Azure SQL.
In SQL Server 2016 and 2017, Microsoft introduced enhancements to reduce TempDB contention. One way to minimize contention is to increase the number of TempDB data files. SQL Server 2016 and 2017 have a configuration option where you can set the number of TempDB files during installation. However, you should not create more files than there are logical cores.
-- T-SQL
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev, SIZE = 10MB);
ALTER DATABASE tempdb
MODIFY FILE (NAME = templog, SIZE = 5MB);
Another approach to reduce contention is to use the version store in TempDB, which is a storage area for data that is replaced by a transaction. This can be done by enabling Read Committed Snapshot Isolation (RCSI) or Snapshot Isolation (SI).
-- T-SQL
ALTER DATABASE YourDatabaseName SET READ_COMMITTED_SNAPSHOT ON;
ALTER DATABASE YourDatabaseName SET ALLOW_SNAPSHOT_ISOLATION ON;
In MySQL 5.7, one way to minimize TempDB contention is by increasing the size of the InnoDB buffer pool. This pool is used to cache data and indexes of its tables. By increasing its size, you can store more data and reduce I/O operations on TempDB.
-- MySQL
SET GLOBAL innodb_buffer_pool_size = size_in_bytes;
In DB2 11.1, you can reduce the contention of the temporary tablespace (similar to TempDB in SQL Server) by creating multiple smaller tablespaces instead of a single large one. This can be done using the CREATE TABLESPACE command.
-- DB2
CREATE TABLESPACE temp_space1 IN DATABASE
PAGESIZE 4096 MANAGED BY SYSTEM USING ('/DB2/temp_space1')
BUFFERPOOL IBMDEFAULTBP
In Azure SQL, you can minimize TempDB contention by scaling up the database. With Azure SQL, you can easily change the service tier, the compute size, and the storage size of your database, which can help you manage the load on TempDB.
In conclusion, TempDB contention can significantly affect the performance of your SQL Server. However, you can use the methods discussed in this post to minimize the impact of contention and ensure your database runs smoothly. Always remember to monitor your database performance regularly to identify and solve any issues as soon as they arise.
Check out the latest articles from all our sites:
- How to Take Advantage of Flash Sales at Grocery Stores [https://www.ethrift.net]
- A brief history of the Galveston Hurricane of 1900 [https://www.galvestonbeachy.com]
- How to Plant and Maintain Chokeberry Bushes [https://www.gardenhomes.org]
- New Query Store Enhancements in SQL Server 2022 [https://www.sqlsupport.org]
- Heat: Why My Laptop Is Cooking My Lap [https://www.SupportMyPC.com]
- The Best Months to Visit South Korea for Cherry Blossoms and Fall Colors [https://www.treasureholidays.com]
Privacy Policy for sqlsupport.org
Last updated: Feb 03, 2026
sqlsupport.org respects your privacy and is committed to protecting any personal information you may provide while using this website.
This Privacy Policy document outlines the types of information that are collected and recorded by sqlsupport.org and how we use it.
Information We Collect
- Internet Protocol (IP) addresses
- Browser type and version
- Pages visited
- Time and date of visits
- Referring URLs
- Device type
Cookies and Web Beacons
sqlsupport.org uses cookies to store information about visitors preferences and to optimize the users experience.
How We Use Your Information
- Operate and maintain our website
- Improve user experience
- Analyze traffic patterns
- Prevent fraudulent activity
Contact
Email: admin@sqlsupport.org