The impact of Tempdb on SQL Server performance optimization and tempdb Performance Optimization
First, consolidate the basic knowledge of tempdb.
Introduction:
Tempdb is an important part of SQLServer, which is used to store tempo
SQL Server uses cursors to deal with the extremely competitive performance of Tempdb-DBA issues-required by programmers, tempdb-dba
Competition in SQL Server tempdb allocation is a common issue for DBAs. Almost all DBAs now know how to create several more files to solve/alleviate the problem. however, deep competition
objectsObjects that store temporary data during a query, such as sorts, spooling, hash associations, and cursors.You can use the following SQL statement to view:SELECT * from Sys.dm_db_session_space_usageView Internal_object_alloc_page_count Columns2.3. Version StorageWhen optimistic concurrency mode is turned on, temp db is used to store the pre-modified version data.Attention:The version store will cause unexpected growth in temp db and requires monitoring of the file size and usage space of
This article discusses how to improve the performance of SQL Server databases. BKJIA database channel recommends "getting started with SQL Server" to help you better understand SQL Server databases.
1. SQL Server System database Introduction
SQL Server has four important system-level databases: master, model, msdb, and tempdb.
Master: records all system-level information of the SQL Server System, including
Unlike other SQL Server databases, tempdb stops at SQL Server and automatically drops and re-create upon restart. by default, a new 8 MB (MDF file: 8 MB; LDF file: 1 MB, autogtouth is set to 10%) recovery model is a simple tempdb database.
After the tempdb database is created, DBA can create data objects, temporary tables, temporary stored procedures, and tabl
by the data modification transaction to implement online index operations, multiple active result sets, and the AFTER trigger.
3. Performance Improvement of tempdb
In SQL Server, the performance of tempdb is improved in the following ways:
1) temporary tables and table variables may be cached. The cache allows you to
stored procedures, temporary storage of large types, intermediate result sets, table variables, and cursors. In addition, it is used to meet all other temporary storage requirements.
2.TEMPDB Internal Operating principle
Unlike other SQL Server databases, tempdb is automatically drop,re-create in the case of SQL Server shutdown and restart. According to the model database, a new 8MB (MDF file:8mb;ldf fil
Tags: des style blog http color os io using strongAll along, in high-load, complex production environments, the pressure of tempdb is one of the most important factors for the entire instance bottleneck. Microsoft engineers are also constantly optimizing its use in various editions. to the SQL SERVER2014 also has a new feature that makes the performance of tempdb
perform better default configuration in the SQL Server Installation Wizard. Configuring TempDb based on the number of available CPU cores is a huge improvement. Let's take a look at the next version to provide the ability to configure MAXDOP, parallel overhead threshold, and maximum server memory according to actual conditions...
Articles you may be interested in:
SQL Server misunderstanding: on the 30 th day, the number of
cannot add more file groups.
4. tempdb is used to store three types of objects: user objects, internal objects, and version storage areas.
The above is the basic knowledge.
If SQL Server does not frequently access tempdb,
Tempdb does not affect the database; on the contrary, if the access is frequent, loading will increase,
The
Optimization of tempdb
By default, the tempdb database is placed on the master device with a capacity of 2 MB, temporary databases are the most common databases used for sorting, creating temporary tables, and re-formatting. Therefore, tempdb optimization should be paid special attention.Step 1: bind the temporary database
[The log of the database 'tempdb' is full] The latest solution, tempdb logThe log of the database 'tempdb' is full.Execute SQL statements. Temporary tables are not used in the middle.Prompt server: Message 9002, Level 17, status 2, Row 1The log of the database 'tempdb' is full. Back up the transaction logs of the datab
can also observe the running status of Log-related performance technicians during execution, for example, Log Bytes Flusged \ sec)
Figure 1-1
From this test, we can see that "tempdb is faster than other databases" mentioned in this article ".
Actually, it is not the magic of tempdb, but the Log Mechanism of tempdb is
more filegroups.
4. Tempdb is used to store three types of objects: User objects, internal objects, version stores
Above is the basic knowledge.
If SQL Server does not have frequent access to tempdb,
Tempdb does not have an impact on the database; Conversely, if the access is frequent, the loading will increase,
The per
. This feature improves the performance of the INSERT statement in tempdb. Also, because tempdb is recreated each time you restart SQL Server, you do not need to log information that is used to re-execute any transactions. Therefore, there are no transactions to roll forward or roll back. When SQL Server starts, re-creates te
(LOB).
A working file for a hash join or hash aggregation operation.
Intermediate sort results for operations such as creating or rebuilding indexes, if specified sort_in_tempdb, or intermediate sorting results for some GROUP by, ORDER by, or UNION queries.
Each internal object uses at least nine pages; an IAM page, a eight-page area. For more information about pages and extents, see pages and extents.The following table lists the features of user objects, internal objects, or row
. type_desc = 'rows '-- put the statement to be measured here SELECT tempdb_read_MB = (SUM (num_of_bytes_read)-@ read)/1024. /1024 ., tempdb_write_MB = (SUM (num_of_bytes_written)-@ write)/1024. /1024 ., internal_use_MB = (SELECT internal_objects_alloc_page_count/128.0 FROM sys. dm_db_task_space_usage WHERE session_id =@spid) FROM tempdb. sys. database_files as dbfjoin sys. dm_io_virtual_file_stats (2, NULL) as fs on fs. file_id = DBF. file_idWHERE DB
while(@i100000)beginInsert into#t1Select @i,'AA'Select @i=@i+1EndSelect [Extime]=DATEDIFFS@t, Sysutcdatetime ())Non-temporal tables are executed in tempdb UsetempdbGoCreate TableT1 (IDint not NULL, str1Char(8000))Declare @tDateTime2=sysutcdatetime ()Declare @i intSet @i=1 while(@i100000)beginInsert intoT1Select @i,'AA'Select @i=@i+1EndSelect [Extime]=DATEDIFFS@t, Sysutcdatetime ())As we can see in Figure 1-1, the execution of a one-minute script i
This article is from http://stackoverflow.com/users/6461/splattne. Thanks to his effort.
In order to optimize tempdb performance pay attention to physical disk configuration, file configuration, as well as some settings within the database.
Physical disk configuration
Tempdb shocould reside on itsOwn dedicated physical disks. This allows it to split I/O
just want you to improve his attention, a lot of system performance problems on him! As always, with an example: the statement is equivalent to "car", the hardware equivalent to "road", waiting for the equivalent of "traffic lights", then what is tempdb equivalent? " Service Area parking " --------------Blog Address--------------------------------------------------------------------------------
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.