Unix Technical Forum

Keep a few connections open all the time or open/close connections on the fly?

This is a discussion on Keep a few connections open all the time or open/close connections on the fly? within the SQL Server forums, part of the Microsoft SQL Server category; --> Just a quick question about connection management. My application will never need more than 1 or 2 connections about ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 05:57 PM
Robin Tucker
 
Posts: n/a
Default Keep a few connections open all the time or open/close connections on the fly?


Just a quick question about connection management. My application will
never need more than 1 or 2 connections about at any given time. Also, I do
not expect many users to be connected at any given time. For efficiency, I
would like to keep connections alive throughout the lifetime of the objects
requiring them, rather than opening a new connection, executing code and
then closing it again. What is the most efficient way of doing this?
Should I perform the open/close or just one open when I create the object
and a close when I dispose of it?



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 05:57 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Keep a few connections open all the time or open/close connections on the fly?

Robin Tucker (r.tucker@thermoteknix.com) writes:
> Just a quick question about connection management. My application will
> never need more than 1 or 2 connections about at any given time. Also,
> I do not expect many users to be connected at any given time. For
> efficiency, I would like to keep connections alive throughout the
> lifetime of the objects requiring them, rather than opening a new
> connection, executing code and then closing it again. What is the most
> efficient way of doing this? Should I perform the open/close or just one
> open when I create the object and a close when I dispose of it?


First of all, what client library are you using?

Some client libraries, ADO and ADO.Net employs connection pooling, so
when you officially disconnects, the client library actually keeps the
connection around for some 60 seconds, in case you like to reuse it.
Connection pooling can be quite essential in web applications.

If you are writing a VB application and you know you will never have
any users connected, I don't see anything wrong in creating a connection
and keep the connection object alive as a global variable.


--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:38 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com