SQL SERVER – Finding The Oldest Query Plan From Cache

Often people ask where do I come up with a new blog idea everyday. Well, answer is that I am not the one who comes up with new idea, it is all of you who inspire everyday with a new idea. Recently one of the healtch check client Comprehensive Database Performance Health Check asked me if there is anyway can see the oldest query plan from the cache for his server.

Read More

SQL SERVER – 5061: FIX Error: ALTER DATABASE failed because a lock could not be placed on database ‘Database Name’. Try again later.

Every consulting engagement is different and I get to learn new things. In this blog post, I will share what I learned during my recent Comprehensive Database Performance Health Check. During health check to demonstrate one of the scenarios we had created a test database in our environment. However, after the test was complete we wanted to take the database offline so we eventually can drop it or bring it online if needed, however, as soon as we ran the command to take database offline, it gave is an error related to alter database failed because a lock could not be placed on database.

Read More

SQL SERVER – Finding User Who Dropped Database Table

Though I mainly focus on SQL Server Performance Tuning as my primary consulting engagement, there are moments when I am asked questions from my regular clients which are not related to SQL Server Performance and they still expect me to answer. I think it is totally fair, no one wants to go to find a new consultant for some simple questions. Recently my customer wanted to know who dropped the database table from their primary database.

Read More

SQL SERVER – Optimize Key Lookup by Creating Index with Include Columns

I love query tuning and performance tuning projects. In one of the recent Comprehensive Database Performance Health Check my client had a very interesting scenario where their queries were running pretty fast earlier but gradually started to run slow and eventually started to take over 10 minutes to execute. They reached out to me to tune their slow running query. While looking at the query execution plan, there is a big key lookup operation which was actually slowing down their query. I decided to create an index with include column on that table and resolve this issue.

Read More