With so many applications being built as SAAS offerings, an important decision that must be made when defining the data architecture is: Should each customers’ data be in a separate database, or can a shared database (keyed by a customer identifier) be used for all customers. Pros of database per customer There’s a variety of […]
Read MoreWhat’s filling up tempdb?
If you’ve ever received an alert that tempdb was running out of space, you probably want to know what session/query is consuming tempdb. There are two ways tempdb gets consumed. User tempdb usage and system tempdb usage. User temdpb usage is related to creating and populating @table variables or #temporary tables and explicitly populating them. […]
Read MorePlan guides made easy
Plan guides are a useful tool for changing an execution plan when despite your best efforts the optimizer just isn’t coming up with the optimal plan. This becomes useful for situations where you can’t make code changes to a query or stored procedure. People are sometimes hesitant to use them due to the complexity in […]
Read MoreTuning Substring Query Without Changing the Query
Introduction The blog shows how to tune a query using substring in the WHERE clause. The tuning solution is to use indexing on a computed column. Performance Issue A General Ledger financial report execution in Financial system takes a long time finishing more than 4 hours. Performance Analysis The first step in the performance tuning […]
Read MoreHow to view query store id’s related to a sql/plan handle or query/plan hash.
On occasion you will have a sql_handle, plan_handle, query_hash, or query_plan_hash and need to know the query store ID related to it. One such example is with a deadlock. Deadlocks contain sql_handles. A key part of diagnosing deadlocks is viewing the execution plan. Query store is a good place to view the execution plan and […]
Read MoreHow to change your default transaction isolation level in SSMS
It’s not uncommon for me to see support professionals running SELECT queries against production databases that cause major performance issues due to shared locks. By default SQL Server Management Studio (SSMS) has its transaction isolation level set to READ COMMITTED. If your support users only have read access to your database I would suggest having […]
Read MoreWhere did that execution plan come from?
I’ve had a lot of cases where I have a developer send over an execution plan and ask me to look at their query. I’m really hesitant to waste time looking at an estimated execution plan rather than a (real) plan retrieved from the plan cache. For a variety of reasons it is best to […]
Read MoreSomething you should know about query timeouts and sys.dm_exec_query_stats
If you’re looking for your worst performers by querying sys.dm_exec_query_stats, be aware queries that are timing out (i.e. “Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding”) do not factor into the statistics shown in sys.dm_exec_query_stats. I’ll show an example of this. Example For this example […]
Read MoreHow to remove a hint from a query without code changes
On occasion I’ve been in situations where I’ve identified a query with a hint applied that was causing degraded performance. In the case of vendor code this can be a problem since removal or changes to hints would require a code change. This can also be a problem in shops where there are strict processes […]
Read MoreHow to see what is in your buffer cache
If you have ever wondered what database or tables/indexes were consuming the most memory/buffer in your database, this post can help with that. How do I see this? The key DMV’s to view this are sys.dm_os_buffer_descriptors, sys.allocation_units, and sys.partitions. The key piece to identifying what is currently in the buffer cache is sys.dm_os_buffer_descriptors. The use […]
Read More