asp.net - Query Time out - sporadic -


have asp.net web application querying data sql server 2005 database. have 1 page sporadically timeout.

traced code , found sql. running sql through query tool , runs under 2 seconds. default timeout sql server 10 minutes.

the fix has been change sql server time out 20 minutes , 10 minutes. page takes 2 seconds query , display.

have looked @ possible locking nothing shows cause problem. conclusion reseting of timeout setting killing process.

looking ideas can traced.

thanks

there 2 different timeouts @ play here. connection timeout (specified in connect string , property of sqlconnection), , query timeout (the property sqlcommand.commandtimeout). default values are:

  • connection timeout: 15 seconds.
  • query timeout: 30 seconds.

query timeout defined "the cumulative time-out network reads during command execution or processing of results. time-out can still occur after first row returned, , not include user processing time, network read time."

lots of reasons why network read time gets consumed (including network contention). things for:

  • blocking in sql server.
  • statistics out of date.
  • execution plan. execution plan in query analyzer?
  • stale/suboptimal execution plan cache. if problem query parameterized stored procedure or query, execution plan cached obtained when query first executed. based on parameter values of first call. if supplied arguments call outlier/non-normal values, cached execution plan may suboptimal executions.
  • stored procedure recompiles. stored procedure interleaves sql/dml , ddl (e.g., interleaves select statements creation of temp tables) cause recompile every temp table creation. compile locks prevent other execs of same stored procedure proceeding until execution plan recompilation completes. if use temp tables, should declare front, prior execution of dml crud.

if specified connect timeout via connection string, existing, pooled sql server connections aren't used: fresh connections connection pool cache based on connect string used. dispose()'ing connectsion/commands/etc.? if leave open reader data read, you're leaving lock in place cause problems. sometime, sql server chokes, drops connection , leaves ghost spid, well, poses similar lock contention issues.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -