Daily Archives: May 5, 2011

ms sql timeout

ok we had a problem on an application… it was really slow and sometimes it resulted in a sql timeout. so sql server(MSSQL 2008 R2) must be slow… no wasnt… network must be slow… no wasnt… app server must be slow… no wasnt… app must be slow… good point… but isnt…

after reading and debuging the sourcecode(code was not mine and coder is on vacation(as usual, when problems pop up…)) the slow sql statement was a view… running the view in the ms sql management studio: instant… hmm… wtf? after a few more tests we figured out, that the problem is based on the sql servers client, and a little bit of randomness…. running the statement on the sql server was instant… running it locally on a computer 23 seconds!.. running it on a virtual maschine, on the same computer… instant… wth? and always in ms sql management studio…

after a few more tries, we saw, that the result of the viw is unsorted… adding a “order by” resulted in the same process speed on all boxes… WTF? but yeah… its the damn solution…