Reputation: 25162
For some reason it takes 7 seconds to open a connection to a sql server database for the firt time, subsequent connections takes a second. any idea what could be the reason?
I'm using C# and asp.net
Its after compilation, i essence every time i restart the site, which means every time it needs to actualy create the "first" connection. i understand that setting up connection pooling has overhead, but i have never seen that i should take 7 second to set it up.
Upvotes: 2
Views: 2507
Reputation: 432210
As well as connection pooling and CLR compilation, don't forget that the data and plan caches on the database server could be "cold" too...
I've seen first calls on a very "cold" web site take 5-10 seconds to respond from button click (for example, "search") to the data ending up on screen.
Upvotes: 1
Reputation: 7976
The first time the connection has to be established which has a lot of overhead. Each subsequent connection is using connection pooling (assuming you have the same connection string) and the initial setup does not need to be done.
Edit: see this link or this one for some info on connection pooling.
Upvotes: 1
Reputation: 8166
is this after a compile each time? Is the "lagtime" due to JIT compiling rather than the SqlConnection itself?
Upvotes: 0