4

In our testing environment, opening a SqlConnection takes around 5 seconds. I would like to investigate why it is taking so long, but I am not sure where to look at. Until the connection is open there are no entries in the SqlProfiler. The sql server (ver 2012) is running on a separate machine and we are connecting to it from another computer in the same network. We see the 5 second freeze in console applications as well as from the IIS (ASP.NET). The communication itself is fast.

Here's a screenshot from dotTrace:

dotTrace

What can I do to investigate what exactly is taking those 5 seconds? Thanks.

Update: Thanks everyone for great comments. It was the authentication - once we switched from integrated to sql authentication, the slowdowns were gone.

Martin Haluza
  • 1,075
  • 7
  • 17
  • 1
    What type of connection is it? (Named pipes, IP...?) What authentication are you using? Have you tried it on other machines? Have you tried it on the same machine as the database? – Jon Skeet Dec 14 '16 at 17:23
  • 1
    is it also slow when SSMS connects from there? consider http://stackoverflow.com/questions/4269268/initial-connection-to-sql-server-connection-is-slow-why – Cee McSharpface Dec 14 '16 at 17:24
  • Drill down further into the stack trace. The screenshot stops short of the conclusion. – usr Dec 14 '16 at 19:02

1 Answers1

6

Here go the usual best bets:

Community
  • 1
  • 1
Cee McSharpface
  • 8,493
  • 3
  • 36
  • 77