开发者

Long time to load first sql connection in .NET

开发者 https://www.devze.com 2022-12-26 13:47 出处:网络
For some reason it takes 7 seconds to open a connection to a sql server database for the firt time, subsequent connections开发者_JS百科 takes a second. any idea what could be the reason?

For some reason it takes 7 seconds to open a connection to a sql server database for the firt time, subsequent connections开发者_JS百科 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.


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.


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.


is this after a compile each time? Is the "lagtime" due to JIT compiling rather than the SqlConnection itself?

0

精彩评论

暂无评论...
验证码 换一张
取 消