Category: Performance Tuning

  • DBA Scripts: Get Blocking Summary

    ,

    When Everything Looks Busy But Nothing Is Moving Blocking is one of the most common causes of a SQL Server that suddenly looks frozen. Applications start timing out, users report that everything has stopped responding, and the server itself looks fine: CPU is low, disk queues are calm, nothing is crashing. Dozens of sessions are…

  • DBA Scripts: Get Temp DB Hotspots

    ,

    Temp DB is shared by every database and every session on the instance: temp tables, table variables, sort and hash spills, version store for snapshot isolation, all of it lands in the same handful of files. When Temp DB is under pressure, contention or growth events, the first question is always “who’s actually using it…

  • DBA Scripts: Get Query Store Top Queries

    ,

    Query Store is SQL Server’s built-in flight recorder for query performance: every query’s plan, runtime stats, and history, retained and queryable without any extra tracing setup. Most instances have had it available since SQL Server 2016, and a surprising number still have it switched off, which means every “what changed” investigation starts from nothing. This…

  • DBA Scripts: Get Query Store Status

    ,

    Query Store is the single most useful diagnostic feature SQL Server has shipped in the last decade, a built-in, per-database history of every query’s plans and runtime stats, no third-party tooling required. And it fails in one of the quietest ways possible: it either isn’t turned on at all, or it’s silently full and has…

  • DBA Scripts: Get Implicit Conversions

    ,

    An indexed lookup is scanning when it should seek, or CPU is climbing with no single query to blame, and the application sends its strings as nvarchar. This script lists every cached statement whose plan carries SQL Server’s implicit conversion warning, the ones that lost an index seek first. Why Implicit Conversions Matter When the…

  • DBA Scripts: Get Statistics Health

    ,

    Query plans are only as good as the statistics SQL Server uses to build them. When a table’s data distribution changes but its statistics don’t get refreshed to match, the optimizer keeps making decisions based on a picture of the data that’s no longer true, choosing a scan when a seek would be faster, or…

  • DBA Scripts: Get Deadlock Summary

    ,

    The application logged Msg 1205 and you need to know which 2 statements collided, on what, and which one lost. SQL Server already recorded the deadlock graph in the built-in system_health Extended Events session, and this script reads it back. Msg 1205 on the victim’s connectionthe symptom, not something to copy Msg 1205, Level 13,…

  • DBA Scripts: Get Blocking Chains

    ,

    A single blocked session is usually easy to spot. The harder case is a chain: session C is waiting on session B, B is waiting on session A, and A is sitting idle holding a lock from a transaction nobody remembers is still open. Killing C does nothing. A is the problem, at the top…

  • DBA Scripts: Get Recent Error Log Entries

    ,

    The SQL Server error log records almost everything worth knowing about an instance’s recent health, and almost nobody reads it until they’re already troubleshooting something. It’s not that the information isn’t there, it’s that xp_readerrorlog returns thousands of lines dominated by routine noise, every successful backup, every log backup, every clean CHECKDB, until the two…

  • DBA Scripts: Remove XE Session

    ,

    An Extended Events session you stood up for a decommission audit, a login trace, or a stored procedure profile isn’t meant to run forever. Once you’ve got the evidence, it’s just overhead, disk space, buffer memory, and one more thing a future DBA has to figure out the purpose of. The trouble is finding every…