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.
Some questions never get old and some question and I believe we will be discussing them for many more years in the future. Just other days, I received this question during my SQL Server Performance Tuning Practical Workshop. The question was about Performance Comparison IN vs OR. Though personally, I have answered this question quite a many times before, let us answer it once again, it never hurts to repeat the truth multiple times.
During SQLPass summit, I was asked following question by one of the attendees. The question was about Performance Comparison of Except vs NOT IN. Let us quickly discuss this question.
Question: Which of the operator is better for query performance – EXCEPT or NOT IN?
The puzzles are interesting and in most cases, if we try to play around a little bit more, many more interesting extensions can be added. A couple of weeks back, I wrote a round – SELECT One by Two – Why Does SELECT 1/2 Returns 0 – Interview Question of the Week #067. It brought some good interactions as comments over the blog and I was happy we were all excited about something as simple as this.
The biggest challenge which we often face as a database person is to compare the value across multiple columns. Trust me, if there were no comparison operators, we would have never got this task done. MySQL supports many comparison operators like BETWEEN, IN, etc. LEAST and GREATEST is very handy if you want to compare values across many columns.
SQL SERVER – Puzzle Involving NULL – Resolve – Error – Operand data type void type is invalid for sum operator
Today is Monday let us start this week with interesting puzzle. Yesterday I had also posted quick question here: SQL SERVER – T-SQL Scripts to Find Maximum between Two Numbers