System.Data.SqlClient.SqlException: Timeout expired

后端 未结 2 1632
我寻月下人不归
我寻月下人不归 2020-12-21 11:27

Coupled days ago I noticed that my web application giving me sql an exception timeout expired.

I cleaned up couple stored procedures taking more cpu and restarted SQ

相关标签:
2条回答
  • 2020-12-21 12:01

    Sounds like leaky behavior. Without knowing your general architecture, I can't say what kind of leak, but I might suggest looking at all your tables and seeing if anything seems to have way more rows than you're expecting.

    You can also run your sprocs manually in SQL Management Studio, and see which ones are taking so long -- maybe you're running an algorithm whose running time increases with uptime.

    0 讨论(0)
  • 2020-12-21 12:07

    Well, to start off, it's the function "UpdateHitCounter" that's proximally causing the problem, but you don't know whether this is a cause or an effect. Your query is exceeding the configured time allotted to complete.

    Whenever you have a poorly performing database, a broad stroke approach you can run on it is to attach Sql Profiler to it, and then execute the Index Tuning Wizard against the results.

    If you want to take a more measured, triage approach, you can restrict the profiler to log only queries that take longer than x seconds to complete, whatever you think x should be. I usually start out at 5 and work down from there if nothing shows up. Here is a primer on that topic.

    Once you identify the long running queries, execute them in a local copy and examine the execution plans. Here is a primer for that, but to start out look for "table scan".

    Ultimately, either your database is suboptimal, or your hardware isn't up to the traffic. It's almost certainly the first, and these two approaches should get you on your way.

    0 讨论(0)
提交回复
热议问题