onsdag 28 augusti 2013

Force prints to display

I you wan't to force print statements to display continuously when executing script in management studio, insert the following statement. SQL server do not treat severity 1-10 as an error, just a message.

RAISERROR ('Push the message!', 0, 1) WITH NOWAIT

torsdag 22 augusti 2013

T-SQl Query performance

Just some short notes on what to be aware of when experiencing bad performance.

  • Table Scans for sure, but also be aware of key-lookups. Those normally can be avoided be including the lookup column in the index. This is in my experience one of the more common opportunities to improve performance and not that obvious to spot.
  •  Table compression actually increases Query performance, but slows inserts down a bit. Generally if you have big tables, use table compression
  • If using a view as a source in a merge statement, you can save a lot of time by doing it in two steps, first store the result of the view in a temporary table and then do the merge with the temporary table as source.
  • A left join can in some cases be faster than an inner join. Strange but true.