Jump to content


Photo

More connects better or less?


  • Please log in to reply
2 replies to this topic

#1 canadium

canadium
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 19 May 2006 - 05:20 AM

Hey everyone. I'm running a site engine with a bunch of different queries, maybe around 25 queries per page view. I am planning to expand to a site with around 100+.

This isn't huge... but I'm just wondering, is it better to do a connect and close mysql command before and after EACH query, or is it better to do one connect command at the beginning of page execution and a close command at the end?

I'm curious about security and efficiency. Is doing more queries a lot more intensive on the server, and if I do one connect and one close is that leaving myself open to attacks?

Thanks,
-Will

#2 jeremywesselman

jeremywesselman
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts
  • LocationIndependence, KY

Posted 19 May 2006 - 05:43 AM

I'll tell you right now that is more effecient to open one connection at the beginning of the page and close it at the end of the page then it is to open and close a new connection for each query. I'm not sure about security, but I don't think you'll have a problem using just one connection per page instead of one connection per query.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

#3 canadium

canadium
  • Members
  • Pip
  • Newbie
  • 3 posts

Posted 19 May 2006 - 07:22 AM

[!--quoteo(post=375147:date=May 19 2006, 12:43 AM:name=jeremywesselman)--][div class=\'quotetop\']QUOTE(jeremywesselman @ May 19 2006, 12:43 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I'll tell you right now that is more effecient to open one connection at the beginning of the page and close it at the end of the page then it is to open and close a new connection for each query. I'm not sure about security, but I don't think you'll have a problem using just one connection per page instead of one connection per query.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]
[/quote]

OK, thanks a lot.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users