473,396 Members | 1,779 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,396 software developers and data experts.

SQL Server ADO/ASP Application and Connections

rob

Hello,

Newbie of sorts. Been reading up on best practices though.

I'm trying to optimize performance to the SQL DB vs. the Web server and
an ASP application. I've read that you're supposed to open late/close
early which makes sense. In the past I'd created a connection and thrown
many queries against the same connection. Now, I'm working with a
recordset object which is returned and the ActiveConnection is closed
after each query. My impression was this was faster ... not sure though.
That might be more of an ASP question but let me elaborate on the SQL
server side:

I was using the SQL Profiler to try to watch connections. I wasn't even
sure what fields to show, but I was watching SPID's and Event Classes
for the user in question. I'd see Audit Login and Audit Logouts, but
wasn't sure how they matched up.

- When I had a single connection object with many queries against them,
there'd be multiple SPID's showing up as Login and Logout.

- When I had multiple connections each with a single query, there'd only
be a single SPID wich each sql query being shown.

My initial assumption was that each SPID was a connection, but I'm
thinking that's not quite right.

Is there a way to watch connections come and go? I'm just using an
ordinary ODBC connection for now.

Any help would be appreciated enormously. Many thanks,

rob


Jul 20 '05 #1
1 3461
rob (ro*@pleaseremovespamcherny.com) writes:
I'm trying to optimize performance to the SQL DB vs. the Web server and
an ASP application. I've read that you're supposed to open late/close
early which makes sense. In the past I'd created a connection and thrown
many queries against the same connection. Now, I'm working with a
recordset object which is returned and the ActiveConnection is closed
after each query. My impression was this was faster ...
Faster and faster... Connecting, disconnecting and reconnecting is fairly
expensive. But so is also keeping a connection alive, on which there
is no traffic. Particularly in web applications where you can have many
users who are logged on at the same time, but who are inactive most of
the time.

To get the best of both worlds, ADO and ADO.Net uses connection pooling,
which means that when you disconnect, they keep the connection alive
for a while, and if you request an new connection, you will get back
the old one. It is tidied up, so it looks new and fresh to you.
- When I had a single connection object with many queries against them,
there'd be multiple SPID's showing up as Login and Logout.
This can happen because ADO and ADO .Net might open a second connection
behind your back, if there is data pending on the first connection.
- When I had multiple connections each with a single query, there'd only
be a single SPID wich each sql query being shown.

My initial assumption was that each SPID was a connection, but I'm
thinking that's not quite right.
Your initial assumption was correct. A spid is a connection. At least
as far as SQL Server is concerned. But the client library blurs the
issue with connection pooling and opening extra connections without
asking you.
Is there a way to watch connections come and go? I'm just using an
ordinary ODBC connection for now.


Yes, that would be the audit login and logout events. Also, if you are
tracing RPC calls, you would see calls to sp_reset_connection. This
happens when a connection is reused for connection pooling.

If you are using plain ODBC, I don't think connection pooling is
available, nor will ODBC open extra connections for you.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

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

Similar topics

2
by: Leon | last post by:
I am trying to using sqlserver as back-end for an application(web) running on the window 2X, one thing I am not sure is that once I establish the connection between database server and application,...
1
by: news.microsoft.com | last post by:
Is there an elegant way to clear out the ADO connection pool used by the SQL Server State Service following a cluster failover? We are using a SQL Cluster to store both the ASP Session State...
3
by: Ken | last post by:
When I run my VB.NET application, it loads a large amount of data upon startup. When I checked Task Manager, it showed that roughly 25% +/- of the processor was being used. When I run the same...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
5
by: Glen Buell | last post by:
Hi all, I have a major problem with my ASP.NET website and it's SQL Server 2005 Express database, and I'm wondering if anyone could help me out with it. This site is on a webhost...
16
by: Wayne | last post by:
Can anyone point me to any info on the pros and cons of upsizing small to medium size databases to SQL Server? If the user base is never going to be more than about 10, the app isn't totally...
11
by: Jeff | last post by:
Hello everyone. I've searched through the archives here, and it seems that questions similar to this one have come up in the past, but I was hoping that I could pick your Pythonic brains a bit. ...
1
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from...
5
by: Cirene | last post by:
I just deployed my new ASP.NET (3.5 FW) site to the hosting company I'm using, webhost4life. NOTE: I HAVE deployed other SQL Server sites to the same account with no issues. Now I'm getting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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,...

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.