Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open/close performance question

Status
Not open for further replies.

maboo59

Programmer
Mar 21, 2005
18
US
I have a question on what is more efficient when opening and closing database connections(using pooling).
I've read that after you have opened a db connection and are then done with it, the close it immediately. Which makes since if you only have to use it once.
What if you have a webpage that has to hit a db many times when a page is opening. Should you open and close after each query? Or leave one db connection open until you have run all the queries then close it?

I welcome any opinions
thanks
maboo59
 
I guess it depends on what you class as more efficient. For example, opening a closing a connection for each query may take more time (in terms of the page processing time) than leaving it open, but leaving it open for each query may mean the the database is running less efficently as it has an open connnection that isn't doing anything in between each query.

Personally I would open and close it each time (as I have a data class that handles open/close commands anyway).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top