Sp-Whoisactive

Tag: sp-whoisactive

How to See Rowcounts and Execution Time for In-Flight Queries in SQL Server

How to See Rowcounts and Execution Time for In-Flight Queries in SQL Server

I frequently need to see rowcounts and execution time for queries while they’re running. Maybe I’m troubleshooting a slow query that’s still executing, or I want to understand which operators are causing the slowdown before the query completes.

Last week at the PASS Summit I learned some little nuances about how this works that I’d missed.

Continue reading

Query Hash Values Are Meaningless in SQL Server: They May Be Reset to Be the Same Value as the Query Plan Hash

Query Hash Values Are Meaningless in SQL Server: They May Be Reset to Be the Same Value as the Query Plan Hash

This is the worst bug I’ve found in SQL Server to date. Previously, my top find was SQL Server Online Index Rebuild sometimes happens offline without warning. This one has taken top slot because it makes my life more difficult on a daily basis.

Background: SQL Server generates a query_hash for each query. This is stored in sys.query_store_query and it’s one of the primary ways you can identify what a query is across different Query Stores, or even the same Query Store over time, as surrogate query_id values get reset if Query Store is cleared or data ages on. The query_hash is a ‘Zobrist hash over the shape of the individual query, based on the bound (input) logical query tree. Query hints aren’t included as part of the hash.’ (Source)

Continue reading

The Learner's Guide to SQL Server Performance Triage

The Learner's Guide to SQL Server Performance Triage

I’m introducing a series of “learner’s guides”: overviews of a given topic, chock full of links and references. For this first post, the information is based on what I learned when I was part of the team at Brent Ozar Unlimited who put together the original First Responder Kit and built a related consulting practice using those tools.

Continue reading

Take the SQLChallenge: Tuning a Stored Procedure

Take the SQLChallenge: Tuning a Stored Procedure

I’ve just published a new SQLChallenge course, and I think it’s one of the best ones yet.

Your mission is to:

  1. Identify which statement is slowing down our stored procedure the most
  2. Tune the code to speed it up. You can change the query that is slow as well as anything else in the procedure that will help you make that statement faster.

In the solution videos, I’ll step through multiple strategies to figure out which statement in the procedure is slowing it down the most – because in real life, you need to have a whole bag of tricks in different situations. 

Continue reading

Finding Queries that Cause Wait Stats in SQL Server

Finding Queries that Cause Wait Stats in SQL Server

You’ve got some troubling wait stats in SQL Server. How can you tell which queries are causing those waits?

Learn the pros and cons of different techniques to track down the cause of both common and tricky waits in SQL Server, including CXPACKET, PAGEIOLATCH, LCK, RESOURCE_SEMAPHORE, and THREADPOOL waits.

Continue reading

Confused by sp_who2 (Dear SQL DBA Episode 30)

Confused by sp_who2 (Dear SQL DBA Episode 30)

This week’s ‘Dear SQL DBA’ question gets us down to the essentials: how to I tell if a transaction is hanging?

Continue reading

Lost in Performance Troubleshooting - Perf Triage for SQL Server

Lost in Performance Troubleshooting - Perf Triage for SQL Server

Psssttt – I have an updated blog post on this called the Learner’s Guide to SQL Server Performance Tuning

The SQL Server is slow, what should you do? I answer a reader question and share my strategy for performance troubleshooting.

Continue reading