473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Slow first connection to SQL Server

I have just started on a new web project. When I make the first connection
to sql server it takes about 10 to 30 seconds (varies each time) to make the
connection to the server. I am using the following code:

Dim cConnStr as String = "myconnectionstring"
Dim oCon as new SqlConnection(cConnStr)
oCon.Open() <-- Slow part

The Open line takes quite a long time.

I can use the exact same code in a windows app with exact same connect
string and it runs immediately on the same machine.

Any ideas what is going on?

I am running XP Pro SP2 and I tried disabling the firewall but it didn't
change anything. I didin't have this problem before I upgraded to Sp2.

Thanks.

Nov 18 '05 #1
9 2800
Is this the first connection after the application has been running, or the
first time the page is hit after a recompile? If the later, it is common to
see a JIT hit. You can avoid it a bit with ngen-ing your assemblies (besides
web app), but you will still see a small hit.

Version 2.0 of the Framework makes this much nicer with precompilation
methods. NOTE: consider a project walker to hit all pages (compile) for your
web apps.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
"Tommy Martin" <tm*****@xspam-tlmartin.com> wrote in message
news:Oq*************@TK2MSFTNGP11.phx.gbl...
I have just started on a new web project. When I make the first connection
to sql server it takes about 10 to 30 seconds (varies each time) to make
the
connection to the server. I am using the following code:

Dim cConnStr as String = "myconnectionstring"
Dim oCon as new SqlConnection(cConnStr)
oCon.Open() <-- Slow part

The Open line takes quite a long time.

I can use the exact same code in a windows app with exact same connect
string and it runs immediately on the same machine.

Any ideas what is going on?

I am running XP Pro SP2 and I tried disabling the firewall but it didn't
change anything. I didin't have this problem before I upgraded to Sp2.

Thanks.

Nov 18 '05 #2
It is the connection itself that is the problem. The page loads very fast.
Its when i click my button and hit the db to get some data that the problem
arises.

The db server is not the same as my development box. I do see that when I
run the code on the same box as the db it is very fast.

I have tried the machine name as well as the ip address in my connect string
and get the same results.

Thanks.

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:O%****************@TK2MSFTNGP12.phx.gbl...
Is this the first connection after the application has been running, or
the first time the page is hit after a recompile? If the later, it is
common to see a JIT hit. You can avoid it a bit with ngen-ing your
assemblies (besides web app), but you will still see a small hit.

Version 2.0 of the Framework makes this much nicer with precompilation
methods. NOTE: consider a project walker to hit all pages (compile) for
your web apps.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
"Tommy Martin" <tm*****@xspam-tlmartin.com> wrote in message
news:Oq*************@TK2MSFTNGP11.phx.gbl...
I have just started on a new web project. When I make the first connection
to sql server it takes about 10 to 30 seconds (varies each time) to make
the
connection to the server. I am using the following code:

Dim cConnStr as String = "myconnectionstring"
Dim oCon as new SqlConnection(cConnStr)
oCon.Open() <-- Slow part

The Open line takes quite a long time.

I can use the exact same code in a windows app with exact same connect
string and it runs immediately on the same machine.

Any ideas what is going on?

I am running XP Pro SP2 and I tried disabling the firewall but it didn't
change anything. I didin't have this problem before I upgraded to Sp2.

Thanks.


Nov 18 '05 #3
Also, here is my connection string if it helps.
"Server=myserver;Database=mydatabase;uid=myid;pwd= mypass;"
"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:O%****************@TK2MSFTNGP12.phx.gbl...
Is this the first connection after the application has been running, or
the first time the page is hit after a recompile? If the later, it is
common to see a JIT hit. You can avoid it a bit with ngen-ing your
assemblies (besides web app), but you will still see a small hit.

Version 2.0 of the Framework makes this much nicer with precompilation
methods. NOTE: consider a project walker to hit all pages (compile) for
your web apps.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
"Tommy Martin" <tm*****@xspam-tlmartin.com> wrote in message
news:Oq*************@TK2MSFTNGP11.phx.gbl...
I have just started on a new web project. When I make the first connection
to sql server it takes about 10 to 30 seconds (varies each time) to make
the
connection to the server. I am using the following code:

Dim cConnStr as String = "myconnectionstring"
Dim oCon as new SqlConnection(cConnStr)
oCon.Open() <-- Slow part

The Open line takes quite a long time.

I can use the exact same code in a windows app with exact same connect
string and it runs immediately on the same machine.

Any ideas what is going on?

I am running XP Pro SP2 and I tried disabling the firewall but it didn't
change anything. I didin't have this problem before I upgraded to Sp2.

Thanks.


Nov 18 '05 #4
"Tommy" <tm*****@xspam-tlmartin.com> wrote in
news:uT**************@TK2MSFTNGP12.phx.gbl:
It is the connection itself that is the problem. The page loads very
fast. Its when i click my button and hit the db to get some data that
the problem arises.


I'm having the same problem as well... I know .NET uses connection pooling,
so maybe the connection pools need to be reinitialized if the connections
have been idle too long?

I haven't figured out why it takes so long relatively speaking to
reconnect.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #5
I thought about that. I created a windows forms app and used the same
technique to connect and it does not show that problem. The connection is
instantanious as it should be.

Only ASP.NET apps are having this problem.

Tommy

"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn**************************@140.99.99.130...
"Tommy" <tm*****@xspam-tlmartin.com> wrote in
news:uT**************@TK2MSFTNGP12.phx.gbl:
It is the connection itself that is the problem. The page loads very
fast. Its when i click my button and hit the db to get some data that
the problem arises.


I'm having the same problem as well... I know .NET uses connection
pooling,
so maybe the connection pools need to be reinitialized if the connections
have been idle too long?

I haven't figured out why it takes so long relatively speaking to
reconnect.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 18 '05 #6
"Tommy Martin" <tm*****@DONTSPAMMEtlmartin.com> wrote in message
news:u%****************@TK2MSFTNGP15.phx.gbl...
I thought about that. I created a windows forms app and used the same
technique to connect and it does not show that problem. The connection is
instantanious as it should be.

Only ASP.NET apps are having this problem.


Hmm - I wonder if it's credentials. When you're using your WinForms app,
you're actually logged on to the machine as yourself but ASP.NET of course
is using its own network login (I don't mean the credentials in the SQL
Connection string).

As a test, can you modify the Web.config temporarily to impersonate yourself
and see if that makes any difference?
Nov 18 '05 #7
Right after <system.web> i added:

<identity impersonate="true"/>

It made no difference.

Tommy
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...
"Tommy Martin" <tm*****@DONTSPAMMEtlmartin.com> wrote in message
news:u%****************@TK2MSFTNGP15.phx.gbl...
I thought about that. I created a windows forms app and used the same
technique to connect and it does not show that problem. The connection is
instantanious as it should be.

Only ASP.NET apps are having this problem.


Hmm - I wonder if it's credentials. When you're using your WinForms app,
you're actually logged on to the machine as yourself but ASP.NET of course
is using its own network login (I don't mean the credentials in the SQL
Connection string).

As a test, can you modify the Web.config temporarily to impersonate
yourself and see if that makes any difference?

Nov 18 '05 #8
"Tommy Martin" <tm*****@DONTSPAMMEtlmartin.com> wrote in message
news:uG**************@TK2MSFTNGP15.phx.gbl...
Right after <system.web> i added:

<identity impersonate="true"/>

It made no difference.


Yes, but which user did you tell it to impersonate...?
Nov 18 '05 #9
Ok.. i told it to use my name and pass and the connection is pretty fast
again. First one is 1 to 2 secs. I can live with that.

This did not used to happen. I wonder if there is some config setting on my
server that needs to be changed or something else in my web.config. I am
using forms authentication in my app.

Thanks for the help.
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:e1**************@TK2MSFTNGP14.phx.gbl...
"Tommy Martin" <tm*****@DONTSPAMMEtlmartin.com> wrote in message
news:uG**************@TK2MSFTNGP15.phx.gbl...
Right after <system.web> i added:

<identity impersonate="true"/>

It made no difference.


Yes, but which user did you tell it to impersonate...?

Nov 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rami Saarinen | last post by:
I have been making a client-server type of software mainly on Linux and now I am trying to get it all work also on windows. However, I am having slight problems running the program in Windows 2000....
2
by: Jim W | last post by:
This is a cross-post from the .NET group since it looks like it may not be ..NET. New information since the original post is that is the wireless network is enabled and connected the socket...
3
by: Harry | last post by:
Using Oracle 8i enterprise on win 2000 (sp3) Installed the standard configuration & whenever I make a connection it takes about 10 secs. It's running on a P1900 with 1gb Ram so no reason there...
11
by: DJJ | last post by:
I am using the MySQL ODBC 3.51 driver to link three relatively small MySQL tables to a Microsoft Access 2003 database. I am finding that the data from the MySQL tables takes a hell of a long time...
1
by: John Morgan | last post by:
I am using a dial up connection to the Internet and to an online SQL Server database. I have a problem in that when I use Enterprise Manager to access even my local server , or even, it...
1
by: Steve D | last post by:
We are using a UDB 8.1 client on a Windows 2003 server, standard edition. We are seeing slow connection response times (27 seconds) on the first attempt and second attempt is great (< 1 second). ...
5
by: Jim W | last post by:
I have an ASP.NET app that has very slow connect times using TCPClient, or the Socket class, or even calling a COM object that uses C socket calls on certain similar XP SP2 boxes. On those...
6
by: B B | last post by:
Okay, here is what's happening: I have a reasonably fast laptop (1.4 GHz Mobile M, so comparable to 2.5GHz P4) doing .net development. Running Windows XP pro, SP2 IIS is installed and running...
3
by: jku | last post by:
Hello, after installing DB2 V8.2.3 on OpenSuse 10.1 (in vmware) we have created a database instance with the restore command: db2 "restore database $OLD_DB user db2inst1 using db2inst1 from...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.