简体   繁体   中英

will opening and closing a mysql connection twice slow down my website significantly more than doing it just once?

I'd like to get an idea of how much of an effect does opening and closing a mysql connection have on the performance of a website. Currently, my PHP website will open and close a mysql connection in two different sections of the code. It is simply much easier for me to leave them separate as they are. I am just worried that I am slowing down my website by a lot. Is my fear unfounded? Or should I stop being lazy and try to cram all my code inside one open and then closed mysql connection instead of opening and closing and then opening and closing a mysql connection twice?

是的...它的效果...不会很大...但是会引起注意的..我是根据我的经验告诉您的...我已经做了两个网络门户....在两种情况下都没有连接顺序打开并强制处理。...结果是每次客户端请求必须发送到服务器并等待服务器响应...在这种情况下,如果您使用的是.net技术,则更喜欢使用数据集...因为它不需要每次都打开数据库连接并将其关闭....它只是将所需(查询的)数据库的副本保存在数据集中并执行操作...谢谢...

Opening and closing mysql connection is not a problem? Speed will become slow when you are using a lot of queries or queries in loop.

For more information see this How to increase speed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM