Speaker: Dennis Gassen

Tempdb Metadata Contention in SQL Server – Table Variable Vs Temporary Table

Tempdb Metadata Contention in SQL Server – Table Variable Vs Temporary Table

In SQL Server, the concurrent creation of temporary tables from many sessions can lead to tempdb metadata contention. Tempdb metadata contention does not affect the concurrent creation of table variables. When SQL Server creates temporary tables, it has to update metadata information in the system based tables, like sys.sysschobjs (like PAGELATCH_EX and PAGELATCH_SH waits). This […]

Read More
AlwaysOn Availability Groups Synchronous Replica Readable Secondary Data Access Latency

AlwaysOn Availability Groups Synchronous Replica Readable Secondary Data Access Latency

With SQL Server AlwaysOn Availability Groups, when you configure a secondary in synchronous-commit mode for read-only access, there can be data access latency. If you make changes to your data like if you perform insert, update or delete in primary, those changes may not be visible in the secondary, synchronous replica enabled for read-only access […]

Read More
Seek or Scan – Cost Based Optimizer in SQL Server

Seek or Scan – Cost Based Optimizer in SQL Server

When SQL Server has a choice of plans, it will compare the cost among a set of execution plans and will choose the cheapest one. In some cases, even though the cost of seek is slightly higher than the cost of scan, SQL Server Optimize might still choose a seek based plan as demonstrated in […]

Read More
Optimize for Ad Hoc Workloads – SQL Server Configuration Parameter

Optimize for Ad Hoc Workloads – SQL Server Configuration Parameter

SQL Server configuration parameter "optimized for ad hoc workloads" can be very useful when you execute lots of single use ad hoc statements or dynamic SQL statements by reducing memory usage of plan cache. If the majority of ad hoc statements or dynamic SQL statements execute more than once, then "optimize for ad hoc workloads" […]

Read More
Extended Event Locks Lock Waits in SQL Server

Extended Event Locks Lock Waits in SQL Server

When it comes to lock waits, one of the important information we need to know is which statement waited for locks and how long. This is possible with extended events; it is not possible with SQL Server profiler. locks_lock_waits event is very useful to find statements that waited for locks more than a certain amount […]

Read More
Extended Event Query Post Execution Showplan in SQL Server

Extended Event Query Post Execution Showplan in SQL Server

Query Post Execution Showplan event is a very useful event to find problematic queries and execution plans based on CPU usage or duration while analyzing performance issues. It can increase the execution time of all queries by a fraction of a millisecond, irrespective of the total query cost, which means, the overhead of query_post_execution_showplan event […]

Read More
PAGELATCH Waits with Update Statements in SQL Server – PAGELATCH_EX and PAGELATCH_SH

PAGELATCH Waits with Update Statements in SQL Server – PAGELATCH_EX and PAGELATCH_SH

In SQL Server, concurrent writes or read / write to the same page can lead to PAGELATCH (like PAGELATCH_EX and PAGELATCH_SH) waits or what is knowns as PAGELATCH contention. One common use case is when invoice numbers are stored in a table. If the row is narrow, then many rows can fit in the 8KB […]

Read More
Tempdb Allocation Contention in SQL Server

Tempdb Allocation Contention in SQL Server

In SQL Server, the concurrent creation of temporary objects (temporary tables and table variables) from many sessions can lead to tempdb allocation contention. This contention occurs on PFS and SGAM pages in tempdb (like PAGELATCH_EX and PAGELATCH_SH waits). It is recommended to create additional data files for tempdb and implement trace flag 1118 to reduce […]

Read More
In-Memory OLTP Memory Optimized Table Variables Vs Disk Based Table Variable in SQL Server

In-Memory OLTP Memory Optimized Table Variables Vs Disk Based Table Variable in SQL Server

Starting SQL Server 2014, it is possible to use memory optimized table variables. These are table variables declared using a table type which is memory optimized. Memory optimized table variables have no disk footprint and don’t have PAGELATCH (like PAGELATCH_EX and PAGELATCH_SH) or LOGBUFFER waits, hence they result in faster performance compared to traditional disk […]

Read More
Temp Table Caching in SQL Server

Temp Table Caching in SQL Server

SQL Server caches temporary objects (temporary tables and table variables), that are created in a stored procedure. Temporary objects that are created either in dynamic SQL statement or by using sp_executesql are not cached. Temp table caching can lead to better performance by reducing Tempdb Allocation Contention. SQL Server will not cache temporary table in […]

Read More
Filtered Statistics in SQL Server

Filtered Statistics in SQL Server

In SQL Server, Filtered Statistics can improve cardinality estimation, i.e. when joining lookup table, or while joining fact table and dimension table. For this reason, SQL Server supports the creation of up to 30,000 statistics on non-indexed columns. Better estimation with filtered statistics can lead to faster query execution against star schema based data warehouses, […]

Read More
Parallel Insert Into – Table Variable Vs Temporary Table in SQL Server

Parallel Insert Into – Table Variable Vs Temporary Table in SQL Server

In SQL Server, for insert into select statements, when the target for insert into is temporary table, the select statement can execute in parallel. When the target is table variable, SQL Server will not execute the select statement in parallel, which can lead to poor performance. The below video demonstrates this with hands-on example. SQLTest […]

Read More