On this page:
Argh... just fought with a small issue where connections to SQL Server were very slow on a new development box. Everytime I make a new SQL Connection there's a 2 second delay for the connection to occur. It's not only the first request, but any connection request including what should otherwise be pooled connections.
As you might imagine in Web applications that's a major problem even on a dev machine - it makes for some excruciatingly slow Web requests.
This is a local dev machine and I have a local SQL Server Developer installed.
TCP/IP is Disabled By DefaultIt turns out that a new SQL Server installation does not enable TCP/IP by default and if you're connecting to the server it uses Named Pipes which on this machine at least results in very slow connection times with what looks like a 2 second delay for every connection.
I was able to duplicate this behavior on two other machines when explicitly disabling TCP/IP and connections appear to take about the same amount of time which is somewhere around 2 seconds.
Enabling TCP/IP solved the problem and made local connections as fast as they should be: Nearly instant.
Enabling TCP/IPTo enable TCP/IP we'll need to set the protocols in the Sql Server Configuration Manager. With recent versions of SQL Server it looks like Microsoft is not longer installing shortcuts for the SQL Server Configuration Manager, so I had to launch it using the mmc and adding the snap-in:
Start the mmc.exe Add the Sql Server Configuration snap-in (ctrl-m -> Sql Server)Once you're there navigate to the Sql Server Network configuration and enable TCP/IP:
Image may be NSFW.
Clik here to view.

Just for good measure I also turned off the other two, but that's optional. Connections are still fast even if the other two are enabled, but TCP/IP is the default protocol so connections are still fast.
Why are Named Pipe Connections so slow?I'm pretty sure that I've used Named Pipes in the past and didn't see this type of slow connection times, but I've verified this on several machines so it's not just a fluke with my new dev box. Each machine I've removed TCP/IP from takes about 2 seconds to connect with either Named Pipes or Shared Memory, while with TCP/IP Connections enabled connections are nearly instant on a local machine. As well it should be.
Anybody have any ideas why Named Pipes are so slow for SQL connections?
SummaryI'm writing this up because I know I'll run into this again next time I install a dev machine or even a new server and hopefully by then I'll remember that I wrote this blog post :smiley:. Maybe it'll help you find the issue this way as well.