A checklist for improving execution time between .NET code and SQL Server. Anything from the basic to weird solutions is appreciated.
Code:
Chan
Weird one that applied to SQL Server 2000 that might still apply today:
Make sure that you aren't trying to dynamically grow the database in production. There comes a point where the amount of time it takes to allocate that extra space and your normal load running will cause your queries to timeout (and the growth too!)
First and foremost - Check the actual query being ran. I use SQL Server Profiler as I setup through my program and check that all my queries are using correct joins and referencing keys when I can.
In the past some of my solutions have been:
Fix the default time out settings of the sqlcommand:
Dim myCommand As New SqlCommand("[dbo].[spSetUserPreferences]", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
myCommand.CommandTimeout = 120
Increase connection timeout string:
Data Source=mydatabase;Initial Catalog=Match;Persist Security Info=True;User ID=User;Password=password;Connection Timeout=120
Increase transaction time-out in sql-server 2005
In management studio’s Tools > Option > Designers Increase the “Transaction time-out after:” even if “Override connection string time-out value for table designer updates” checked/unchecked.
Convert dynamic stored procedures into static ones
Make the code call a stored procedure instead of writing an inline sql statement in the code.
A few quick ones...
A weird "solution" for complaints on long response time is to have a more interesting progress bar. Meaning, work on the user's feeling. One example is the Windows Vista wait icon. That fast rotating circle gives the feeling things are going faster. Google uses the same trick on Android (at least the version I've seen).
However, I suggest trying to address the technical problem first, and working on human behavior only when you're out of choices.
Run Profiler to measure the execution time of your queries.
Check application logging for any deadlocks.