SQL Server 2019 Express Edition with C# commandtime outs starting to occur frequently.

Darryl Hoar 116 Reputation points
2021-05-14T17:04:23.913+00:00

I have created a c# application using .NET 4.5.2 framework. It uses a SQL database I created in SQL Server 2019 express edition. The problem I am experiencing is now that I have been using my application for some months and the database has some size, the Sql commands sent from my c# app to Sql Server and failing to complete with commandtimout errors. If I specify a commandtimeout value (ie override the default 30 seconds) it works, but it bothers me that this happens. Am I going to have to continually bump the commandtimeout value as the database grows ?

It isn't one table or stored procedure that is getting timed out, it is all of them.

Ideas and thoughts greatly appreciated.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,766 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,280 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,555 questions
{count} votes

3 answers

Sort by: Most helpful
  1. David Browne - msft 3,766 Reputation points
    2021-05-14T17:37:30.91+00:00

    You'll need to troubleshoot your query performance to determine why your queries are running so long. So turn on the Query Store and look for long-running and expensive queries.

    0 comments No comments

  2. Erland Sommarskog 101.4K Reputation points MVP
    2021-05-14T21:41:45.83+00:00

    In addition to what David says, also check for blocking. Although, if the problem goes away with extending the command timeout, blocking may not be the primary reason. Then again, if there is an update operation that takes a long time, that is going affect all queries.

    It is actually quite easy to determine this from the Query Store data, because if the execution time is 35 seconds, and the CPU time is just 1-2 seconds, it is very likely due to blocking.

    In the end, you will need to start to considering better indexing for your database.

    0 comments No comments

  3. Darryl Hoar 116 Reputation points
    2021-05-18T13:25:03.643+00:00

    Interesting side note: No changes to the database and the application worked without any changes to the commandtimeout value. Strange.

    I'll do the following:

    1. Evaluate the current table indexes and refine.
    2. Try and examine the Query Store data to determine slowness cause(s).

    Since the computer is not close to me, I can't do the plan examination which I assume I need to do during execution.

    Thanks.