DBAs should know some usage of SQL Server trace tag _ MySQL

Source: Internet
Author: User
Tags server error log
DBAs should be aware of the use of bitsCN.com for SQL Server trace tags. What is a trace tag?

For DBAs, mastering Trace Flag is one of the necessary conditions for them to become masters of SQL Server. In most cases, Trace Flag is just a rare trick, but in many cases, these tags allow you to better control SQL Server behaviors.

Below are official Trace flags:

A trace tag is a tag used to enable or disable certain behaviors of SQL Server.

From the above definition, it is not difficult to see that Trace Flag is a way to control the behaviors of SQL Server. Many DBAs have some misunderstandings about Trace Flag. They believe that Trace Flag can only be used in testing and development environments. this idea can only be partially correct. Therefore, Trace Flag can be divided into two types, suitable for use in the production environment and not suitable for use in the production environment.

Important: Trace Flag is the preferred method. before using Trace Flag for optimization, Apply the basic Best Practice.

How to control trace tags

There are three ways to control the trace tag:

1. run the DBCC command

You can use the DBCC command to enable or disable the trace tag. the advantage of this method is that it is easy to use. you can use the following three commands to disable the status of the viewed trace tag:

Dbcc traceon (2203,-1) dbcc traceoff (, 1) DBCC TRACESTATUS

The second TRACEON and TRACEOFF parameters represent the range of Enable flag, 1 is Session Scope, and-1 is Global Scope. if this value is not specified, the default value is Session Scope.

In addition, if you want to control certain flags by running the DBCC command at each startup of the SQL Server service, use

EXEC sp_procoption @ProcName = '
 
  '   , @OptionName = ] 'startup'   , @OptionValue = 'on'; 
 

This stored procedure is specified. the sp_procoption stored procedure is automatically executed when the SQL Server is started.

It is worth noting that not all trace tags can be started with the DBCC command. for example, Flag 835 can only be specified through the startup parameter.

2. specify

This method is to add startup parameter settings to the database engine startup item, and only Global Scope is available. The format is-T # trace Mark 1; T trace Mark 2; T trace Mark 3.

3. start through the registry

This method is similar to Method 2.


Some tracing tags that may be required in the production environment

Trace Flag 610
Reduce log generation. If you use a lot of basic best practice for logs, such as only one log file, an appropriate number of VLF files, and independent storage, if the log is too large, consider using this trace mark.

References:

http://msdn.microsoft.com/en-us/library/dd425070.aspx
Http://blogs.msdn.com/ B /sqlserverstorageengine/archive/2008/10/24/new-update-on-minimal-logging-for-sql-server-2008.aspx
Trace Flag 834
Use Microsoft Windows large page buffer pool allocation. If the Server is a dedicated SQL Server, it is worth enabling this trace mark.
Trace Flag 835
SQL Server 2005 and 2008 Standard versions are allowed to use the "lock memory page", which is similar to the results set in the group policy, but can be used in the standard version.
Trace Flag 1118
Tempdb allocates the entire zone instead of the hybrid zone, reducing SGAM page competition.
When applying tempdb's best practice, you may also encounter a race problem. consider using this trace tag.
References:
Http://blogs.msdn.com/ B /psssql/archive/2008/12/17/sql-server-2005-and-2008-trace-flag-1118-t1118-usage.aspx
Trace Flag 1204 and 1222
Both trace tags write deadlocks to error logs, but 1204 is in text format, and 1222 is saved in XML format. You can use
Sp_readerrorlogView Logs.
Trace Flag 1211 and 1224
Both methods disable lock upgrade. However, the behavior is different. 1211 means that no lock upgrade will be performed at any time, and 1224 will enable the lock upgrade when the memory pressure is high, thus avoiding the out-of-locks error. When both trace tags are enabled, 1211 has a higher priority.
Trace Flag 2528
Disable parallel execution of dbcc checkdb, dbcc checkfilegroup, and dbcc checktable. This means that these commands can only be executed in a single thread, which may take more time, but it is still useful in some specific situations.
Trace Flag 3226  
Prevents successful log backup. If log backup is too frequent, a large number of error logs will be generated. enabling this trace mark will make log backup no longer recorded in error logs.
Trace Flag 4199
All KB patches take effect for the query analyzer behavior modification. This command is dangerous and may be called as performance degradation. for details, see:
http://support.microsoft.com/kb/974006
Trace flag should not be enabled in the production environment
Trace Flag 806 
 
Check the logical consistency of pages during reading. the following information is displayed in the error log:
 
11:29:04. 11 spid51 error: 823, severity: 24-day status: 2
11:29:04. 11 spid51 I/O error (audit failed) offset detected during reading the subject SQL Server/MSSQL/data/pubs. mdf e:/0x000000000b0000 in the Program file.
 
References: http://support.microsoft.com/kb/841776
 
This trail tag greatly reduces performance !!!

Trace Flag 818 
 
Check write consistency
Mark 818 enables an in-memory ring buffer to track the last 2,048 successful write operations (excluding sorting and working file I/O) executed by the computer running SQL Server ). When an error such as 605, 823, or 3448 occurs, compare the log serial number (LSN) value of the input buffer with the latest write list. If the LSN retrieved during the read operation is older than the LSN specified during the write operation, a new error message is recorded in the SQL Server error log. Most SQL Server write operations appear in the form of checkpoints or inert writes. Inert write is a background task that uses asynchronous I/O operations. The implementation of the circular buffer is lightweight, so the impact on system performance can be ignored.

References: http://support.microsoft.com/kb/826433

Trace Flag 1200 
 
The whole process of returning the lock information is a sign of learning the lock process. The sample code is as follows:
 
DBCC TRACEON(1200,-1)DBCC TRACEON(3604)DBCC TRACESTATUSSELECT * FROM AdventureWorks.person.Address
 
References:
http://stackoverflow.com/questions/7449061/nolock-on-a-temp-table-in-sql-server-2008

Trace Flag 1806
 
Disable instant file initialization. all disk space requests are initialized by entering 0, which may cause blocking when space increases.
 
Trace Flag 3502
The checkpoint information is displayed in the log. 1.
Figure 1. display Checkpoint in the error log

Trace Flag 3505
Automatic checkpoint is not allowed, and checkpoint can only be performed manually. it is a very dangerous command.
 
Summary

Tracking flags are a way to control SQL Server behaviors. for some trace flags, performance can be improved in the production environment, while for others, it is very dangerous to use it in a production environment. it can only be used in a testing environment. Keep in mind that the tracking tag is a method of extreme stability for optimization. it is considered to be used only after all basic optimization methods are used.
BitsCN.com

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.