tempdb 데이터베이스tempdb database
적용 대상:Applies to: SQL ServerSQL Server(지원되는 모든 버전)
SQL ServerSQL Server (all supported versions)
Azure SQL DatabaseAzure SQL Database
Azure SQL DatabaseAzure SQL Database
SQL ServerSQL Server(지원되는 모든 버전)
SQL ServerSQL Server (all supported versions)
Azure SQL DatabaseAzure SQL Database
Azure SQL DatabaseAzure SQL Database
tempdb
시스템 데이터베이스는 SQL ServerSQL Server의 인스턴스 또는 Azure SQL Database에 연결된 모든 사용자가 사용할 수 있는 전역 리소스입니다.The tempdb
system database is a global resource that's available to all users connected to the instance of SQL ServerSQL Server or connected to Azure SQL Database. tempdb
에 보관되는 내용은 다음과 같습니다.tempdb
holds:
명시적으로 생성되는 임시 사용자 개체.Temporary user objects that are explicitly created. 여기에는 전역 또는 로컬 임시 테이블과 인덱스, 임시 저장 프로시저, 테이블 변수, 테이블 반환 함수에서 반환된 테이블, 커서 등이 포함됩니다.They include global or local temporary tables and indexes, temporary stored procedures, table variables, tables returned in table-valued functions, and cursors.
데이터베이스 엔진에서 만든 내부 개체Internal objects that the database engine creates. 다음과 같은 변경 내용이 해당됩니다.They include:
- 스풀, 커서, 정렬 및 임시 LOB(Large Object) 스토리지에 대한 중간 결과를 저장할 작업 테이블Work tables to store intermediate results for spools, cursors, sorts, and temporary large object (LOB) storage.
- 해시 조인 또는 해시 집계 작업에 대한 작업 파일Work files for hash join or hash aggregate operations.
- 인덱스 생성 또는 다시 작성(
SORT_IN_TEMPDB
가 지정된 경우), 특정GROUP BY
,ORDER BY
,UNION
쿼리 같은 작업의 중간 정렬 결과Intermediate sort results for operations such as creating or rebuilding indexes (ifSORT_IN_TEMPDB
is specified), or certainGROUP BY
,ORDER BY
, orUNION
queries.
각 내부 개체는 IAM 페이지와 8페이지 익스텐트를 포함하여 최소 9페이지를 사용합니다.Each internal object uses a minimum of nine pages: an IAM page and an eight-page extent. 페이지 및 익스텐트에 대한 자세한 내용은 페이지 및 익스텐트를 참조하세요.For more information about pages and extents, see Pages and extents.
중요
Azure SQL Database 단일 데이터베이스 및 탄력적 풀은
tempdb
에 저장되고 데이터베이스 수준을 범위로 하는 전역 임시 테이블 및 전역 임시 저장 프로시저를 지원합니다.Azure SQL Database single databases and elastic pools support global temporary tables and global temporary stored procedures that are stored intempdb
and are scoped to the database level.글로벌 임시 테이블 및 글로벌 임시 저장 프로시저는 동일한 SQL 데이터베이스 내의 모든 사용자 세션에 대해 공유됩니다.Global temporary tables and global temporary stored procedures are shared for all users' sessions within the same SQL database. 다른 SQL 데이터베이스의 사용자 세션은 전역 임시 테이블에 액세스할 수 없습니다.User sessions from other SQL databases can't access global temporary tables. 자세한 내용은 데이터베이스 범위 전역 임시 테이블(Azure SQL Database)을 참조하세요.For more information, see Database scoped global temporary tables (Azure SQL Database). Azure SQL Managed Instance는 SQL Server에서 지원하는 것과 동일한 임시 개체를 지원합니다.Azure SQL Managed Instance supports the same temporary objects as does SQL Server.
Azure SQL Database 단일 데이터베이스와 탄력적 풀의 경우 master 데이터베이스 및
tempdb
데이터베이스만 적용됩니다.For Azure SQL Database single databases and elastic pools, only the master database andtempdb
database apply. 자세한 내용은 Azure SQL Database 서버란?을 참조하세요.For more information, see What is an Azure SQL Database server?. Azure SQL Database 단일 데이터베이스와 탄력적 풀의 컨텍스트에서tempdb
의 설명은 Azure SQL Database 단일 데이터베이스와 탄력적 풀의 tempdb 데이터베이스를 참조하세요.For a discussion oftempdb
in the context of Azure SQL Database single databases and elastic pools, see tempdb database in Azure SQL Database single databases and elastic pools.Azure SQL Managed Instance의 경우 모든 시스템 데이터베이스가 적용됩니다.For Azure SQL Managed Instance, all system databases apply.
버전 저장소는 행 버전 관리 기능을 지원하는 데이터 행이 보관된 데이터 페이지 모음입니다.Version stores, which are collections of data pages that hold the data rows that support features for row versioning. 일반 버전 저장소와 온라인 인덱스 작성 버전 저장소의 두 가지 유형이 있습니다.There are two types: a common version store and an online-index-build version store. 버전 저장소에는 다음 정보가 포함됩니다.The version stores contain:
- 행 버전 관리 격리 또는 스냅샷 격리 트랜잭션을 통해
READ COMMITTED
를 사용하는 데이터베이스의 데이터 수정 트랜잭션에서 생성된 행 버전Row versions that are generated by data modification transactions in a database that usesREAD COMMITTED
through row versioning isolation or snapshot isolation transactions. - 온라인 인덱스 작업, MARS(Multiple Active Result Sets) 및
AFTER
트리거 같은 기능에 대한 데이터 수정 트랜잭션에서 생성된 행 버전Row versions that are generated by data modification transactions for features, such as online index operations, Multiple Active Result Sets (MARS), andAFTER
triggers.
- 행 버전 관리 격리 또는 스냅샷 격리 트랜잭션을 통해
트랜잭션을 롤백할 수 있도록 tempdb
내의 작업은 최소한으로 로깅됩니다.Operations within tempdb
are minimally logged so that transactions can be rolled back. 시스템이 항상 깨끗한 데이터베이스 복사본으로 시작되도록 SQL ServerSQL Server를 시작할 때마다 tempdb
가 다시 생성됩니다.tempdb
is re-created every time SQL ServerSQL Server is started so that the system always starts with a clean copy of the database. 연결이 끊길 때 임시 테이블 및 저장 프로시저는 자동으로 제거되고 시스템이 종료될 때 활성 상태인 연결이 없습니다.Temporary tables and stored procedures are dropped automatically on disconnect, and no connections are active when the system is shut down.
tempdb
에 있는 어떠한 내용도 SQL ServerSQL Server의 한 세션에서 다른 세션으로 저장되지 않습니다.tempdb
never has anything to be saved from one session of SQL ServerSQL Server to another. tempdb
에서는 백업 및 복원 작업이 허용되지 않습니다.Backup and restore operations are not allowed on tempdb
.
SQL Server에서 tempdb의 물리적 속성Physical properties of tempdb in SQL Server
다음 표에는 SQL Server의 tempdb
데이터 및 로그 파일의 초기 구성 값이 나열되어 있습니다.The following table lists the initial configuration values of the tempdb
data and log files in SQL Server. 값은 model
데이터베이스의 기본값을 기준으로 합니다.The values are based on the defaults for the model
database. 이러한 파일의 크기는 SQL ServerSQL Server 버전에 따라 조금씩 다를 수 있습니다.The sizes of these files might vary slightly for different editions of SQL ServerSQL Server.
파일File | 논리적 이름Logical name | 물리적 이름Physical name | 처음 크기Initial size | 파일 증가File growth |
---|---|---|---|---|
주 데이터Primary data | tempdevtempdev | tempdb.mdftempdb.mdf | 8MB8 megabytes | 디스크가 꽉 찰 때까지 64MB씩 자동 증가Autogrow by 64 MB until the disk is full |
보조 데이터 파일Secondary data files | temp#temp# | tempdb_mssql_#.ndftempdb_mssql_#.ndf | 8MB8 megabytes | 디스크가 꽉 찰 때까지 64MB씩 자동 증가Autogrow by 64 MB until the disk is full |
로그Log | templogtemplog | templog.ldftemplog.ldf | 8MB8 megabytes | 최대 2TB까지 64MB씩 자동 증가Autogrow by 64 megabytes to a maximum of 2 terabytes |
보조 데이터 파일의 수는 컴퓨터의 논리 프로세서 수에 따라 달라집니다.The number of secondary data files depends on the number of (logical) processors on the machine. 일반적으로 논리 프로세서의 수가 8 이하인 경우 논리 프로세서와 같은 수의 데이터 파일을 사용합니다.As a general rule, if the number of logical processors is less than or equal to eight, use the same number of data files as logical processors. 논리 프로세서 수가 8보다 크면 8개의 데이터 파일을 사용합니다.If the number of logical processors is greater than eight, use eight data files. 그런 다음에도 경합이 계속될 경우 경합이 허용 가능한 수준으로 감소할 때까지 데이터 파일의 수를 4의 배수로 늘리거나 작업/코드를 변경합니다.Then if contention continues, increase the number of data files by multiples of four until the contention decreases to acceptable levels, or make changes to the workload/code.
참고
데이터 파일 수의 기본값은 KB 2154845의 일반 지침을 기준으로 합니다.The default value for the number of data files is based on the general guidelines in KB 2154845.
참고
tempdb
의 현재 크기 및 성장 매개 변수를 확인하려면 tempdb.sys.database_files
뷰를 쿼리합니다.To check current size and growth parameters for tempdb
, query view tempdb.sys.database_files
.
SQL Server에서 tempdb 데이터 및 로그 파일 이동Moving the tempdb data and log files in SQL Server
tempdb
데이터 및 로그 파일을 이동하려면 시스템 데이터베이스 이동을 참조하세요.To move the tempdb
data and log files, see Move system databases.
SQL Server에서 tempdb에 대한 데이터베이스 옵션Database options for tempdb in SQL Server
다음 표에서는 tempdb
데이터베이스의 각 데이터베이스 옵션에 대한 기본값과 수정 가능 여부를 나열합니다.The following table lists the default value for each database option in the tempdb
database and whether the option can be modified. 이러한 옵션의 현재 설정을 보려면 sys.databases 카탈로그 뷰를 사용하세요.To view the current settings for these options, use the sys.databases catalog view.
데이터베이스 옵션Database option | 기본값Default value | 수정 가능Can be modified |
---|---|---|
ALLOW_SNAPSHOT_ISOLATIONALLOW_SNAPSHOT_ISOLATION | OFFOFF | 예Yes |
ANSI_NULL_DEFAULTANSI_NULL_DEFAULT | OFFOFF | 예Yes |
ANSI_NULLSANSI_NULLS | OFFOFF | 예Yes |
ANSI_PADDINGANSI_PADDING | OFFOFF | 예Yes |
ANSI_WARNINGSANSI_WARNINGS | OFFOFF | 예Yes |
ARITHABORTARITHABORT | OFFOFF | 예Yes |
AUTO_CLOSEAUTO_CLOSE | OFFOFF | 예No |
AUTO_CREATE_STATISTICSAUTO_CREATE_STATISTICS | 켜기ON | 예Yes |
AUTO_SHRINKAUTO_SHRINK | OFFOFF | 예No |
AUTO_UPDATE_STATISTICSAUTO_UPDATE_STATISTICS | 켜기ON | 예Yes |
AUTO_UPDATE_STATISTICS_ASYNCAUTO_UPDATE_STATISTICS_ASYNC | OFFOFF | 예Yes |
CHANGE_TRACKINGCHANGE_TRACKING | OFFOFF | 예No |
CONCAT_NULL_YIELDS_NULLCONCAT_NULL_YIELDS_NULL | OFFOFF | 예Yes |
CURSOR_CLOSE_ON_COMMITCURSOR_CLOSE_ON_COMMIT | OFFOFF | 예Yes |
CURSOR_DEFAULTCURSOR_DEFAULT | GLOBALGLOBAL | 예Yes |
데이터베이스 가용성 옵션Database Availability Options | ONLINEONLINE MULTI_USERMULTI_USER READ_WRITEREAD_WRITE |
예No 예No 예No |
DATE_CORRELATION_OPTIMIZATIONDATE_CORRELATION_OPTIMIZATION | OFFOFF | 예Yes |
DB_CHAININGDB_CHAINING | 켜기ON | 예No |
ENCRYPTIONENCRYPTION | OFFOFF | 예No |
MIXED_PAGE_ALLOCATIONMIXED_PAGE_ALLOCATION | OFFOFF | 예No |
NUMERIC_ROUNDABORTNUMERIC_ROUNDABORT | OFFOFF | 예Yes |
PAGE_VERIFYPAGE_VERIFY | SQL ServerSQL Server 새 설치의 경우 CHECKSUM입니다.CHECKSUM for new installations of SQL ServerSQL Server SQL ServerSQL Server 업그레이드의 경우 NONE입니다.NONE for upgrades of SQL ServerSQL Server |
예Yes |
PARAMETERIZATIONPARAMETERIZATION | SIMPLESIMPLE | 예Yes |
QUOTED_IDENTIFIERQUOTED_IDENTIFIER | OFFOFF | 예Yes |
READ_COMMITTED_SNAPSHOTREAD_COMMITTED_SNAPSHOT | OFFOFF | 예No |
RECOVERYRECOVERY | SIMPLESIMPLE | 예No |
RECURSIVE_TRIGGERSRECURSIVE_TRIGGERS | OFFOFF | 예Yes |
Service Broker 옵션Service Broker Options | ENABLE_BROKERENABLE_BROKER | 예Yes |
TRUSTWORTHYTRUSTWORTHY | OFFOFF | 예No |
이러한 데이터베이스 옵션에 대한 자세한 내용은 ALTER DATABASE SET 옵션(Transact-SQL)을 참조하세요.For a description of these database options, see ALTER DATABASE SET Options (Transact-SQL).
SQL Database의 tempdb 데이터베이스tempdb database in SQL Database
DTU 기반 서비스 계층에 대한 tempdb 크기tempdb sizes for DTU-based service tiers
서비스 수준 목표Service-level objective | tempdb 데이터 파일 최대 크기(GB)Maximum tempdb data file size (GB) |
tempdb 데이터 파일 수Number of tempdb data files |
tempdb 데이터 최대 크기(GB)Maximum tempdb data size (GB) |
---|---|---|---|
BasicBasic | 13.913.9 | 11 | 13.913.9 |
S0S0 | 13.913.9 | 11 | 13.913.9 |
S1S1 | 13.913.9 | 11 | 13.913.9 |
S2S2 | 13.913.9 | 11 | 13.913.9 |
S3S3 | 3232 | 11 | 3232 |
S4S4 | 3232 | 22 | 6464 |
S6S6 | 3232 | 33 | 9696 |
S7S7 | 3232 | 66 | 192192 |
S9S9 | 3232 | 1212 | 384384 |
S12S12 | 3232 | 1212 | 384384 |
P1P1 | 13.913.9 | 1212 | 166.7166.7 |
P2P2 | 13.913.9 | 1212 | 166.7166.7 |
P4P4 | 13.913.9 | 1212 | 166.7166.7 |
P6P6 | 13.913.9 | 1212 | 166.7166.7 |
P11P11 | 13.913.9 | 1212 | 166.7166.7 |
P15P15 | 13.913.9 | 1212 | 166.7166.7 |
기본 탄력적 풀(모든 DTU 구성)Basic Elastic Pools (all DTU configurations) | 13.913.9 | 1212 | 166.7166.7 |
표준 탄력적 풀(50 eDTU)Standard Elastic Pools (50 eDTU) | 13.913.9 | 1212 | 166.7166.7 |
표준 탄력적 풀(100 eDTU)Standard Elastic Pools (100 eDTU) | 3232 | 11 | 3232 |
표준 탄력적 풀(200 eDTU)Standard Elastic Pools (200 eDTU) | 3232 | 22 | 6464 |
표준 탄력적 풀(300 eDTU)Standard Elastic Pools (300 eDTU) | 3232 | 33 | 9696 |
표준 탄력적 풀(400 eDTU)Standard Elastic Pools (400 eDTU) | 3232 | 33 | 9696 |
표준 탄력적 풀(800 eDTU)Standard Elastic Pools (800 eDTU) | 3232 | 66 | 192192 |
표준 탄력적 풀(1200 eDTU)Standard Elastic Pools (1200 eDTU) | 3232 | 1010 | 320320 |
표준 탄력적 풀(1600-3000 eDTU)Standard Elastic Pools (1600-3000 eDTU) | 3232 | 1212 | 384384 |
프리미엄 탄력적 풀(모든 DTU 구성)Premium Elastic Pools (all DTU configurations) | 13.913.9 | 1212 | 166.7166.7 |
vCore 기반 서비스 계층에 대한 tempdb 크기tempdb sizes for vCore-based service tiers
vCore 기반 리소스 제한 참조See vCore-based resource limits.
제한 사항Restrictions
tempdb
데이터베이스에서는 다음 작업을 수행할 수 없습니다.The following operations can't be performed on the tempdb
database:
- 파일 그룹 추가Adding filegroups.
- 데이터베이스 백업 또는 복원Backing up or restoring the database.
- 데이터 정렬 변경.Changing collation. 기본 데이터 정렬은 서버 데이터 정렬입니다.The default collation is the server collation.
- 데이터베이스 소유자 변경.Changing the database owner.
tempdb
는 sa 가 소유합니다.tempdb
is owned by sa. - 데이터베이스 스냅샷 만들기Creating a database snapshot.
- 데이터베이스 삭제Dropping the database.
- 데이터베이스에서 guest 사용자 삭제Dropping the guest user from the database.
- 변경 데이터 캡처 사용Enabling Change Data Capture.
- 데이터베이스 미러링 참여Participating in database mirroring.
- 주 파일 그룹, 주 데이터 파일 또는 로그 파일 제거Removing the primary filegroup, primary data file, or log file.
- 데이터베이스 또는 주 파일 그룹 이름 바꾸기Renaming the database or primary filegroup.
DBCC CHECKALLOC
를 실행하고 있습니다.RunningDBCC CHECKALLOC
.DBCC CHECKCATALOG
를 실행하고 있습니다.RunningDBCC CHECKCATALOG
.- 데이터베이스를
OFFLINE
으로 설정합니다.Setting the database toOFFLINE
. - 데이터베이스 또는 주 파일 그룹 이름을
READ_ONLY
로 바꿉니다.Setting the database or primary filegroup toREAD_ONLY
.
사용 권한Permissions
모든 사용자가 tempdb
에 임시 개체를 만들 수 있습니다.Any user can create temporary objects in tempdb
. 사용자가 추가 사용 권한을 받는 경우를 제외하고 자신의 고유 개체에만 액세스할 수 있습니다.Users can access only their own objects, unless they receive additional permissions. tempdb
에 대한 연결 권한을 철회하여 사용자가 tempdb
를 사용하지 못하게 할 수 있습니다.It's possible to revoke the connect permission to tempdb
to prevent a user from using tempdb
. 일부 루틴 작업은 tempdb
를 사용해야 하기 때문에 권장하지 않습니다.We don't recommend it because some routine operations require the use of tempdb
.
SQL Server에서 tempdb 성능 최적화Optimizing tempdb performance in SQL Server
tempdb
데이터베이스의 크기와 물리적인 배치는 시스템 성능에 영향을 줄 수 있습니다.The size and physical placement of the tempdb
database can affect the performance of a system. 예를 들어 tempdb
에 대해 정의된 크기가 너무 작으면 사용자가 SQL ServerSQL Server 인스턴스를 다시 시작할 때마다 시스템의 처리 로드 중 일부가 작업을 지원하는 데 필요한 크기로 tempdb
를 자동 증가시키기 위해 소모될 수 있습니다.For example, if the size that's defined for tempdb
is too small, part of the system-processing load might be taken up with autogrowing tempdb
to the size required to support the workload every time you restart the instance of SQL ServerSQL Server.
가능하면 데이터 파일 증가 작업의 성능을 향상시키기 위해 인스턴트 파일 초기화를 사용하세요.If possible, use instant file initialization to improve the performance of growth operations for data files.
환경의 일반적인 작업량을 수용할 수 있는 값으로 파일 크기를 설정하여 모든 tempdb
파일에 충분한 공간을 미리 할당합니다.Preallocate space for all tempdb
files by setting the file size to a value large enough to accommodate the typical workload in the environment. 미리 할당하면 tempdb
가 너무 자주 확장되어 성능에 영향을 주는 것을 방지할 수 있습니다.Preallocation prevents tempdb
from expanding too often, which affects performance. tempdb
데이터베이스는 예기치 않은 예외 발생 시 디스크 공간을 늘리기 위해 자동 증가하도록 설정해야 합니다.The tempdb
database should be set to autogrow to increase disk space for unplanned exceptions.
SQL ServerSQL Server에서는 여유 공간이 더 많은 파일에 할당을 선호하는 비례 채우기 알고리즘을 사용하기 때문에 데이터 파일은 각 파일 그룹 내에서 동일한 크기여야 합니다.Data files should be of equal size within each filegroup, because SQL ServerSQL Server uses a proportional-fill algorithm that favors allocations in files with more free space. tempdb
를 동일한 크기의 여러 데이터 파일로 나누면 tempdb
를 사용하는 작업에서 높은 수준의 병렬 효율성을 얻을 수 있습니다.Dividing tempdb
into multiple data files of equal size provides a high degree of parallel efficiency in operations that use tempdb
.
파일 증가분을 적정 크기로 설정하여 tempdb
데이터베이스 파일 증가 단위가 너무 작지 않게 합니다.Set the file growth increment to a reasonable size to prevent the tempdb
database files from growing by too small a value. tempdb
에 기록되는 데이터 양에 비해 파일 증가 단위가 너무 작으면 tempdb
가 지속적으로 확장되어If the file growth is too small compared to the amount of data that's being written to tempdb
, tempdb
might have to constantly expand. 성능에 영향을 줍니다.That will affect performance.
현재 tempdb
크기 및 성장 매개 변수를 확인하려면 다음 쿼리를 사용합니다.To check current size and growth parameters for tempdb
, use the following query:
SELECT name AS FileName,
size*1.0/128 AS FileSizeInMB,
CASE max_size
WHEN 0 THEN 'Autogrowth is off.'
WHEN -1 THEN 'Autogrowth is on.'
ELSE 'Log file grows to a maximum size of 2 TB.'
END,
growth AS 'GrowthValue',
'GrowthIncrement' =
CASE
WHEN growth = 0 THEN 'Size is fixed.'
WHEN growth > 0 AND is_percent_growth = 0
THEN 'Growth value is in 8-KB pages.'
ELSE 'Growth value is a percentage.'
END
FROM tempdb.sys.database_files;
GO
tempdb
데이터베이스를 고속 I/O 하위 시스템에 배치합니다.Put the tempdb
database on a fast I/O subsystem. 직접 연결되어 있는 디스크가 많으면 디스크 스트라이프를 사용합니다.Use disk striping if there are many directly attached disks. tempdb
데이터 파일의 개별 또는 그룹은 I/O 병목 상태가 발생하지 않는 한, 다른 디스크나 스핀들에 있을 필요가 없습니다.Individual or groups of tempdb
data files don't necessarily need to be on different disks or spindles unless you're also encountering I/O bottlenecks.
사용자 데이터베이스에 사용되는 디스크와는 다른 디스크에 tempdb
데이터베이스를 배치합니다.Put the tempdb
database on disks that differ from the disks that user databases use.
SQL Server tempdb의 성능 향상Performance improvements in tempdb for SQL Server
SQL Server 2016(13.x)SQL Server 2016 (13.x)부터, tempdb
성능은 다음과 같은 방법으로 더욱 최적화되었습니다.Starting with SQL Server 2016(13.x)SQL Server 2016 (13.x), tempdb
performance is further optimized in the following ways:
- 임시 테이블과 테이블 변수가 캐시됩니다.Temporary tables and table variables are cached. 캐싱을 사용하면 임시 개체를 삭제하고 만드는 작업이 매우 신속하게 실행됩니다.Caching allows operations that drop and create the temporary objects to run very quickly. 캐싱은 페이지 할당과 메타데이터 경합을 줄입니다.Caching also reduces page allocation and metadata contention.
- 사용되는
UP
(업데이트) 래치 수가 감소하도록 할당 페이지 래치 프로토콜이 개선되었습니다.The allocation page latching protocol is improved to reduce the number ofUP
(update) latches that are used. tempdb
로그 파일의 디스크 I/O 대역폭 사용량을 줄일 수 있도록tempdb
의 로깅 오버헤드가 감소했습니다.Logging overhead fortempdb
is reduced to reduce disk I/O bandwidth consumption on thetempdb
log file.- 설치 시에는 새 인스턴스를 설치하는 동안
tempdb
데이터 파일이 여러 개 추가됩니다.Setup adds multipletempdb
data files during a new instance installation. 데이터베이스 엔진 구성 섹션의 새 UI 입력 컨트롤과 명령줄 매개 변수/SQLTEMPDBFILECOUNT
를 사용하여 이 작업을 수행할 수 있습니다.You can accomplish this task by using the new UI input control in the Database Engine Configuration section and the command-line parameter/SQLTEMPDBFILECOUNT
. 설치 시에는 기본적으로 논리 프로세서 수나 8 중에서 더 적은 숫자에 해당하는 만큼의tempdb
데이터 파일이 추가됩니다.By default, setup adds as manytempdb
data files as the logical processor count or eight, whichever is lower. tempdb
데이터 파일이 여러 개이면 모든 파일은 증가 설정에 따라 동시에 같은 크기만큼 증가합니다.When there are multipletempdb
data files, all files autogrow at the same time and by the same amount, depending on growth settings. 추적 플래그 1117이 더 이상 필요하지 않습니다.Trace flag 1117 is no longer required.tempdb
의 모든 할당에는 단일 범위가 사용됩니다.All allocations intempdb
use uniform extents. 추적 플래그 1118은 더 이상 필요하지 않습니다.Trace flag 1118 is no longer required.- 주 파일 그룹의 경우
AUTOGROW_ALL_FILES
속성이 설정되며 수정할 수 없습니다.For the primary filegroup, theAUTOGROW_ALL_FILES
property is turned on and the property can't be modified.
tempdb
의 성능 개선에 대한 자세한 내용은 블로그 게시물 TEMPDB - Files and Trace Flags and Updates, Oh My!를 참조하세요.For more information on performance improvements in tempdb
, see the blog article TEMPDB - Files and Trace Flags and Updates, Oh My!.
메모리 최적화 tempdb 메타데이터Memory-optimized tempdb metadata
tempdb
의 메타데이터 경합으로 인해 기존에는 SQL ServerSQL Server에서 실행하는 많은 워크로드의 확장성에 병목 상태가 발생했습니다.Metadata contention in tempdb
has historically been a bottleneck to scalability for many workloads running on SQL ServerSQL Server. SQL Server 2019 (15.x)SQL Server 2019 (15.x)에는 메모리 내 데이터베이스 기능 제품군에 속하는 새로운 기능인 메모리 액세스에 최적화된 tempdb 메타데이터가 도입되었습니다.introduces a new feature that's part of the in-memory database feature family: memory-optimized tempdb metadata.
이 기능은 이러한 병목 현상을 효과적으로 제거하고 tempdb가 많은 워크로드에 대해 새로운 수준의 확장성을 발휘할 수 있도록 합니다.This feature effectively removes this bottleneck and unlocks a new level of scalability for tempdb-heavy workloads. SQL Server 2019 (15.x)SQL Server 2019 (15.x)에서 임시 테이블 메타데이터 관리에 필요한 시스템 테이블은 래치가 없는 비내구성 메모리 최적화 테이블로 이동할 수 있습니다.In SQL Server 2019 (15.x)SQL Server 2019 (15.x), the system tables involved in managing temporary table metadata can be moved into latch-free, non-durable, memory-optimized tables.
메모리 최적화 tempdb 메타데이터를 사용하는 방법과 시기에 대한 개요는 7분 분량의 다음 동영상을 시청하세요.Watch this seven-minute video for an overview of how and when to use memory-optimized tempdb metadata:
메모리 최적화 tempdb 메타데이터 구성 및 사용Configuring and using memory-optimized tempdb metadata
해당 새 기능으로 옵트인하려면 다음 스크립트를 사용합니다.To opt in to this new feature, use the following script:
ALTER SERVER CONFIGURATION SET MEMORY_OPTIMIZED TEMPDB_METADATA = ON;
이 구성 변경이 적용되려면 서비스를 다시 시작해야 합니다.This configuration change requires a restart of the service to take effect.
다음 T-SQL 명령을 사용하여 tempdb
가 메모리 최적화인지 여부를 확인할 수 있습니다.You can verify whether or not tempdb
is memory-optimized by using the following T-SQL command:
SELECT SERVERPROPERTY('IsTempdbMetadataMemoryOptimized');
메모리 최적화 tempdb
메타데이터를 사용하도록 설정한 후 어떤 이유로든 서버를 시작할 수 없는 경우, -f 시작 옵션을 통해 minimal 구성으로 SQL Server 인스턴스를 시작하여 기능을 무시할 수 있습니다.If the server fails to start for any reason after you enable memory-optimized tempdb
metadata, you can bypass the feature by starting the SQL Server instance with minimal configuration through the -f startup option. 이후 기능을 사용하지 않도록 설정한 다음 표준 모드로 SQL Server를 다시 시작할 수 있습니다.You can then disable the feature and restart SQL Server in normal mode.
서버 메모리 부족을 방지하기 위해 tempdb
를 리소스 풀에 바인딩할 수 있습니다.To protect the server from potential out-of-memory conditions, you can bind tempdb
to a resource pool. 이 작업은 리소스 풀을 데이터베이스에 바인딩하기 위해 일반적으로 수행하는 단계가 아니라 ALTER SERVER
명령을 통해 수행됩니다.This is done through the ALTER SERVER
command rather than the steps you would normally follow to bind a resource pool to a database.
ALTER SERVER CONFIGURATION SET MEMORY_OPTIMIZED TEMPDB_METADATA = ON (RESOURCE_POOL = 'pool_name');
메모리 최적화 tempdb 메타데이터를 이미 사용하도록 설정한 경우에도 이 변경을 적용하려면 다시 시작해야 합니다.This change also requires a restart to take effect, even if memory-optimized tempdb metadata is already enabled.
메모리 최적화 tempdb 제한 사항Memory-optimized tempdb limitations
기능 설정 및 해제가 동적으로 이루어지지 않습니다.Toggling the feature on and off is not dynamic.
tempdb
의 구조를 변경해야 하는 고유한 사항 때문에 이 기능을 설정하거나 해제하려면 다시 시작해야 합니다.Because of the intrinsic changes that need to be made to the structure oftempdb
, a restart is required to either enable or disable the feature.단일 트랜잭션이 둘 이상의 데이터베이스에서는 메모리 최적화 테이블에 액세스할 수 없습니다.A single transaction is not allowed to access memory-optimized tables in more than one database. 사용자 데이터베이스에 메모리 최적화 테이블을 포함하는 트랜잭션은 동일한 트랜잭션에서
tempdb
시스템 보기에 액세스할 수 없습니다.Any transactions that involve a memory-optimized table in a user database won't be able to accesstempdb
system views in the same transaction. 사용자 데이터베이스의 메모리 최적화 테이블과 동일한 트랜잭션에서tempdb
시스템 보기에 액세스를 시도하면 다음과 같은 오류가 발생합니다.If you try to accesstempdb
system views in the same transaction as a memory-optimized table in a user database, you'll receive the following error:A user transaction that accesses memory optimized tables or natively compiled modules cannot access more than one user database or databases model and msdb, and it cannot write to master.
예:Example:
BEGIN TRAN; SELECT * FROM tempdb.sys.tables; -----> Creates a user in-memory OLTP transaction in tempdb INSERT INTO <user database>.<schema>.<mem-optimized table> VALUES (1); ----> Tries to create a user in-memory OLTP transaction in the user database but will fail COMMIT TRAN;
메모리 최적화 테이블에 대한 쿼리가 잠금 및 분리 힌트를 지원하지 않으므로, 메모리 최적화
tempdb
카탈로그 보기에 대한 쿼리는 잠금 및 분리 힌트를 유지하지 않습니다.Queries against memory-optimized tables don't support locking and isolation hints, so queries against memory-optimizedtempdb
catalog views won't honor locking and isolation hints. SQL ServerSQL Server의 다른 시스템 카탈로그 보기와 마찬가지로 시스템 보기에 대한 모든 트랜잭션은READ COMMITTED
(또는 이 경우READ COMMITTED SNAPSHOT
) 분리 내에 있습니다.As with other system catalog views in SQL ServerSQL Server, all transactions against system views will be inREAD COMMITTED
(or in this case,READ COMMITTED SNAPSHOT
) isolation.메모리 최적화
tempdb
메타데이터가 사용하도록 설정된 경우에는 임시 테이블에 columnstore 인덱스를 만들 수 없습니다.Columnstore indexes can't be created on temporary tables when memory-optimizedtempdb
metadata is enabled.columnstore 인덱스에 대한 제한으로 인해, 메모리 최적화
tempdb
메타데이터가 사용하도록 설정된 경우COLUMNSTORE
또는COLUMNSTORE_ARCHIVE
데이터 압축 매개 변수와 함께sp_estimate_data_compression_savings
시스템 저장 프로시저를 사용할 수 없습니다.Due to the limitation on columnstore indexes, use of thesp_estimate_data_compression_savings
system stored procedure with theCOLUMNSTORE
orCOLUMNSTORE_ARCHIVE
data compression parameter is not supported when memory-optimizedtempdb
metadata is enabled.
참고
이러한 제한 사항은 tempdb
시스템 보기를 참조하는 경우에만 적용됩니다.These limitations apply only when you're referencing tempdb
system views. 원하는 경우 사용자 데이터베이스에서 메모리 최적화 테이블에 액세스할 때와 동일한 트랜잭션에서 임시 테이블을 만들 수 있습니다.You can create a temporary table in the same transaction as you access a memory-optimized table in a user database, if desired.
SQL Server의 tempdb 용량 계획Capacity planning for tempdb in SQL Server
SQL ServerSQL Server 프로덕션 환경에서 tempdb
의 적절한 크기는 많은 요인에 따라 결정됩니다.Determining the appropriate size for tempdb
in a SQL ServerSQL Server production environment depends on many factors. 앞서 설명한 것처럼 기존 작업, 사용된 SQL ServerSQL Server 기능 등이 이러한 요인에 포함됩니다.As described earlier, these factors include the existing workload and the SQL ServerSQL Server features that are used. SQL Server 테스트 환경에서 다음 태스크를 수행하여 기존 작업을 분석하는 것이 좋습니다.We recommend that you analyze the existing workload by performing the following tasks in a SQL Server test environment:
tempdb
에 대해 자동 증가를 설정합니다.Set autogrow on fortempdb
.- 개별 쿼리 또는 워크로드 추적 파일을 실행하고
tempdb
공간 사용을 모니터링합니다.Run individual queries or workload trace files and monitortempdb
space use. - 인덱스 다시 작성 및
tempdb
공간 모니터링 같은 인덱스 유지 관리 작업을 실행합니다.Execute index maintenance operations such as rebuilding indexes, and monitortempdb
space. - 이전 단계의 공간 사용 값을 사용하여 총 워크로드 사용량을 예측합니다.Use the space-use values from the previous steps to predict your total workload usage. 예상되는 동시 작업에 맞춰 이 값을 조정한 다음
tempdb
크기를 적절하게 설정합니다.Adjust this value for projected concurrent activity, and then set the size oftempdb
accordingly.
tempdb 사용 모니터링Monitoring tempdb use
tempdb
의 디스크 공간이 부족하면 SQL ServerSQL Server 프로덕션 환경에서 심각한 중단이 발생할 수 있습니다.Running out of disk space in tempdb
can cause significant disruptions in the SQL ServerSQL Server production environment. 또한 실행 중인 애플리케이션에서 작업을 완료하지 못할 수도 있습니다.It can also prevent applications that are running from completing operations. sys.dm_db_file_space_usage 동적 관리 뷰를 사용하여 tempdb
파일에서 사용되는 디스크 공간을 모니터링할 수 있습니다.You can use the sys.dm_db_file_space_usage dynamic management view to monitor the disk space that's used in the tempdb
files:
-- Determining the amount of free space in tempdb
SELECT SUM(unallocated_extent_page_count) AS [free pages],
(SUM(unallocated_extent_page_count)*1.0/128) AS [free space in MB]
FROM sys.dm_db_file_space_usage;
-- Determining the amount of space used by the version store
SELECT SUM(version_store_reserved_page_count) AS [version store pages used],
(SUM(version_store_reserved_page_count)*1.0/128) AS [version store space in MB]
FROM sys.dm_db_file_space_usage;
-- Determining the amount of space used by internal objects
SELECT SUM(internal_object_reserved_page_count) AS [internal object pages used],
(SUM(internal_object_reserved_page_count)*1.0/128) AS [internal object space in MB]
FROM sys.dm_db_file_space_usage;
-- Determining the amount of space used by user objects
SELECT SUM(user_object_reserved_page_count) AS [user object pages used],
(SUM(user_object_reserved_page_count)*1.0/128) AS [user object space in MB]
FROM sys.dm_db_file_space_usage;
sys.dm_db_session_space_usage 및 sys.dm_db_task_space_usage 동적 관리 뷰를 사용하면 세션이나 태스크 수준에서 tempdb
의 페이지 할당 또는 할당 해제 작업을 모니터링할 수 있습니다.To monitor the page allocation or deallocation activity in tempdb
at the session or task level, you can use the sys.dm_db_session_space_usage and sys.dm_db_task_space_usage dynamic management views. 이러한 보기를 사용하면 tempdb
디스크 공간을 많이 사용하는 큰 쿼리, 임시 테이블 또는 테이블 변수를 식별할 수 있습니다.These views can help you identify large queries, temporary tables, or table variables that are using lots of tempdb
disk space. 또한 여러 가지 카운터를 사용하여 tempdb
에서 사용 가능한 여유 공간과 tempdb
를 사용 중인 리소스를 모니터링할 수도 있습니다.You can also use several counters to monitor the free space that's available in tempdb
and the resources that are using tempdb
.
-- Obtaining the space consumed by internal objects in all currently running tasks in each session
SELECT session_id,
SUM(internal_objects_alloc_page_count) AS task_internal_objects_alloc_page_count,
SUM(internal_objects_dealloc_page_count) AS task_internal_objects_dealloc_page_count
FROM sys.dm_db_task_space_usage
GROUP BY session_id;
-- Obtaining the space consumed by internal objects in the current session for both running and completed tasks
SELECT R2.session_id,
R1.internal_objects_alloc_page_count
+ SUM(R2.internal_objects_alloc_page_count) AS session_internal_objects_alloc_page_count,
R1.internal_objects_dealloc_page_count
+ SUM(R2.internal_objects_dealloc_page_count) AS session_internal_objects_dealloc_page_count
FROM sys.dm_db_session_space_usage AS R1
INNER JOIN sys.dm_db_task_space_usage AS R2 ON R1.session_id = R2.session_id
GROUP BY R2.session_id, R1.internal_objects_alloc_page_count,
R1.internal_objects_dealloc_page_count;;
관련 콘텐츠Related content
인덱스에 대한 SORT_IN_TEMPDB 옵션 SORT_IN_TEMPDB option for indexes
시스템 데이터베이스 System databases
sys.databases sys.databases
sys.master_files sys.master_files
데이터베이스 파일 이동Move database files