Just like Windows when you install a SQL Server, it’s more a generalist then a specialist. Trace flags is the road to follow when you as a DBA want to tune your SQL server to look like either a F1 car for OLTP or an Optimus prime monster-truck-like-Australian road-train for DWH queries. Both of them are extremely powerful in their own field, but the key is to use that power correctly.
First things firsts, while a lot of the trace flags mentioned in this blogpost are quite safe to use, some of them are not, so as usual handle with care and knowledge. As such this blogpost is not responsible for any damage to any environment due to careless use of any of these parameters.
So don’t activate them blindly, use them thoughtfully and to your advantage.
These are the trace flags I would expect to see on a well configured SQL Server. These can be used with low to moderate risk.
1117: This flag forces all data files in a file group to grow at once, which reduces “hot spots” of data pages. This ensures that all databases with more than one data file will grow properly across all the data mounts, which in turn ensures maximum physical I/O performance.
1118: Switches allocations in tempdb from 1 page at a time (for the first 8 pages) to one extent. There is now a cache of temp tables. When a new temp table is created on a cold system it uses the same mechanism as it did in SQL 8. When it is dropped though, instead of all the pages being deallocated completely, one IAM page & one data page are left allocated, then the temp table is put into a special cache. Subsequent temp table creations will search in the cache for a pre-created temp table. If one is found, this avoids accessing the allocation bitmaps completely. The temp table cache isn’t huge (32 tables), but this can still lead to a big drop in latch contention in tempdb. For more info, please see this blogpost.
2371: This trace flag comes right out of the SAP recommendations and needs SQL 10.5 SP1 or higher. This trace flag changes how automatic statistics are triggered. On enabling this flag, the standard 20% changes to a dynamic value if the table has over 25000 rows, reducing as the count increases.
2562: This trace flag also needs SQL 10.5 or higher. When enabled it runs the DBCC CHECKDB command in a single “batch” regardless of the number of indexes in the database. By default, the DBCC CHECKDB command tries to minimize tempdb resources by limiting the number of indexes or “facts” that it generates by using a “batches” concept. This trace flag forces all processing into one batch. As such this flag improves the internal processing for determining which pages to read from the database. This reduces the contention on the DBCC_MULTIOBJECT_SCANNER latch.
3226: This trace flag actually makes the SQL logs readable as it suppresses BACKUP COMPLETED log entries going to WIN and SQL logs.
4199: Trace flag 4199 is used to collect hotfixes that were intended to become on-by-default in a future release, whereas other trace flags were used for situations in which a fix was not intended to become on-by-default in current form. Starting with SQL Server 2016 RTM, the database COMPATIBILITY_LEVEL 130 setting will be used to enable trace flag 4199-related hotfixes on-by-default. It contains the following query optimizer changes, previously made under multiple trace flags: 4101-4111,4115-4117,4119-4122,4124-4129,4131-4133,4135 (Note that it doesn’t contain 4130!).
Data warehouses being the massively IO hungry beasts that they are require very specific trace flags. This is especially true when you’re trying to keep your system as fragmentation-free as possible.
610: This trace flag enables minimal logged mode for non-empty B-Tree’s. When you insert a large amount of data regularly, you don’t want to create a lot of transaction log when it’s not needed. This trace flag is typically used for ETL or DWH servers but even OLTP servers that have bulk loading in their process flow can benefit from this trace flag. It is mainly used to reduce the size of the transaction log. There are cases where performance might be better, this is not the main goal of this Trace flag.
1117: Was used to increase performance and ensures maximum physical I/O performance.
-E Technically this is not a trace flag but a startup parameter. You need it when your DWH is running on normal SAS drives but has a negative impact on SSD’s, so be careful. This parameter increases the number of extents that are allocated for each file in a filegroup. This option may be helpful for data warehouse applications that have a limited number of users running index or data scans. It should not be used in other applications because it might adversely affect performance.
Consider your machine to be large, when you have at least 256 GB Ram and 8 or more cores per socket
8048: Newer hardware with multi-core CPUs can present more than 8 CPUs within a single NUMA node. Microsoft has observed that when you approach and exceed 8 CPUs per node the NODE based partitioning may not scale as well for specific query patterns, using trace flag 8048 all NODE based partitioning is upgraded to CPU based partitioning. Remember, this requires more memory overhead but can provide performance increases on these systems.
1236: FIX: Performance problems occur when database lock activity increases in SQL Server, is only needed when you’re running on SQL Server editions lower then 2014SP1 or 2012SP3 when you see elevated values occur for the LOCK_HASH spinlock count.
8015: Creates Soft Numa should only be used on single socket/numa machines with a processors exceeding 8 cores (for example the monstrous E 5-2687W v4, E5-2697A v4 or E5-2697 v4 processors, boasting 12,16 and 18 cores on one processor. Another possible case are VM’s that only show one Numa-Node to the guest machine. You should be careful to use it on machines that are using two or more sockets because you cannot create soft-NUMA’s that includes CPUs from different hardware NUMA nodes. On single socket SMB machines there will be only have one hard-numa and increased I/O and lazy writer bottlenecks might occur. The reason for this is that there is only a single I/O thread and a single lazy writer thread for each NUMA node. Depending on the usage of the database, these single threads may be a significant performance bottleneck. Configuring multiple soft-NUMA nodes provides more I/O threads and more lazy writer threads, which could increase performance. Please note that only the SQL Server scheduler and SQL Server Network Interface (SNI) are soft-NUMA aware. Memory nodes are created based on hardware NUMA and therefore not impacted by soft-NUMA.
834: Allows large-page allocations for the memory that is allocated for the buffer. Large pages are allocated at startup and are kept throughout the lifetime of the process. Trace flag 834 improves performance by increasing the efficiency of the translation look-aside buffer (TLB) in the CPU. Because of that it applies only to the 64-bit versions and you should have the Lock pages in memory right granted to turn this on. On the down side, it might prevent the server from starting if the memory is too fragmented and large pages cannot be allocated.
845: Enables lock pages in Memory for the 64 bit SQL Server non enterprise edition. Please note that Startup time of SQL Server might take longer because SQL Server will allocate all its memory up to the Max Server Memory setting.
836: Uses the max server memory option for the buffer pool and causes SQL Server to size the buffer pool at startup based to the value of the max server mem option instead of the total physical memory. By doing this it will reduce the number of buffer descriptors that are allocated at startup.
1140: TempDB fix for SQL2008 & SQL2005 as described in KB2000471.
1204: Returns the resources and types of locks participating in a deadlock and also the current command affected. In SQL 2012 or higher I prefer to use extended events.
1222: Returns the resources and types of locks that are participating in a deadlock and also the current command affected, in an XML format that does not comply with any XSD. In SQL 2012 or higher I prefer to use extended events.
1224: Disables lock escalation based on the number of locks while retaining memory lock escalation. The Database Engine will now only escalate row or page locks to table (or partition) locks if the amount of memory used by lock objects exceeds one of the following conditions:
1236: Fixes the Elevated values for LOCK_HASH spinlock count in SQL 2012,2014 and 2016.
1807: Enables option to have database files on SMB share for SQL Server 2008 and 2008R2.
2335: Generates a plan that is more conservative in terms of memory consumption when executing the query for SQL 2008R2,2012,2014 and 2016 as the engine will occasionally generate an inefficient plan for a specific query when you configure a large value for max server memory. Using 2335 as a startup parameter will cause SQL Server to generate a plan that is more conservative in terms of memory consumption when executing queries. It does not limit how much memory SQL Server can use. The memory configured for SQL Server will still be used by data cache, query execution & other consumers.
2430: FIX: Large queries that modify data run slower than expected when many locks accumulate in a SQL Server 2008 R2 or in SQL Server 2012.
2453: FIX: Poor performance when you use table variables in SQL Server 2012 or SQL Server 2014.
2470: FIX: Slow performance when an AFTER trigger runs on a partitioned table in SQL Server 2008 R2 or in SQL Server 2012.
2549: This trace flag also needs SQL10.5 or higher, and improves DBCC CHECKDB because when this trace flag is enabled, each database file is assumed to be on a unique disk drive. Do not use this trace flag unless you know that each file is based on a unique physical disk. KB 2634571
As a DBA we sometimes have to live with the terror better known as Hints that “help” us to solve issues forced upon our poor query engine, or as Brent Ozar calls it… SQL Server has a couple of similar features that might make your queries faster today – but they’ll make you sing the blues tomorrow.
The problem we’re often facing as a DBA, is how to stop singing the blues, when a third party application is hammering our engines with their hints… We can solve that, but know that when you simply kill all the hints, you just might get better performance but for the same amount of money, it might send your response times right down the drain. So tread carefully here. Please note that these trace flags do not take into consideration any plan guides that might got sneaked in so they are no “silver bullet”.
4136: Forces OPTIMIZE FOR UNKNOWN on SQL Server 2008R2,2012,2014,2016
6498: Increases Query Compilation Scalability in SQL2014
8602: Disable Query Hints on SQL Server 2012,2014,2016
8722: Disable ALL hints except locking Hints for SQL Server 2012,2014,2016
8755: Disables Locking Hints for SQL 2012,2014,2016
As always, tweak carefully.
© 2023 Kohera
Crafted by
© 2022 Kohera
Crafted by
Cookie | Duration | Description |
---|---|---|
ARRAffinity | session | ARRAffinity cookie is set by Azure app service, and allows the service to choose the right instance established by a user to deliver subsequent requests made by that user. |
ARRAffinitySameSite | session | This cookie is set by Windows Azure cloud, and is used for load balancing to make sure the visitor page requests are routed to the same server in any browsing session. |
cookielawinfo-checkbox-advertisement | 1 year | Set by the GDPR Cookie Consent plugin, this cookie records the user consent for the cookies in the "Advertisement" category. |
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
CookieLawInfoConsent | 1 year | CookieYes sets this cookie to record the default button state of the corresponding category and the status of CCPA. It works only in coordination with the primary cookie. |
elementor | never | The website's WordPress theme uses this cookie. It allows the website owner to implement or change the website's content in real-time. |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Cookie | Duration | Description |
---|---|---|
__cf_bm | 30 minutes | Cloudflare set the cookie to support Cloudflare Bot Management. |
pll_language | 1 year | Polylang sets this cookie to remember the language the user selects when returning to the website and get the language information when unavailable in another way. |
Cookie | Duration | Description |
---|---|---|
_ga | 1 year 1 month 4 days | Google Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors. |
_ga_* | 1 year 1 month 4 days | Google Analytics sets this cookie to store and count page views. |
_gat_gtag_UA_* | 1 minute | Google Analytics sets this cookie to store a unique user ID. |
_gid | 1 day | Google Analytics sets this cookie to store information on how visitors use a website while also creating an analytics report of the website's performance. Some of the collected data includes the number of visitors, their source, and the pages they visit anonymously. |
ai_session | 30 minutes | This is a unique anonymous session identifier cookie set by Microsoft Application Insights software to gather statistical usage and telemetry data for apps built on the Azure cloud platform. |
CONSENT | 2 years | YouTube sets this cookie via embedded YouTube videos and registers anonymous statistical data. |
vuid | 1 year 1 month 4 days | Vimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. |
Cookie | Duration | Description |
---|---|---|
ai_user | 1 year | Microsoft Azure sets this cookie as a unique user identifier cookie, enabling counting of the number of users accessing the application over time. |
VISITOR_INFO1_LIVE | 5 months 27 days | YouTube sets this cookie to measure bandwidth, determining whether the user gets the new or old player interface. |
YSC | session | Youtube sets this cookie to track the views of embedded videos on Youtube pages. |
yt-remote-connected-devices | never | YouTube sets this cookie to store the user's video preferences using embedded YouTube videos. |
yt-remote-device-id | never | YouTube sets this cookie to store the user's video preferences using embedded YouTube videos. |
yt.innertube::nextId | never | YouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen. |
yt.innertube::requests | never | YouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen. |
Cookie | Duration | Description |
---|---|---|
WFESessionId | session | No description available. |