[英]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. 我想知道打开和关闭mysql连接对网站的性能有多大影响。 Currently, my PHP website will open and close a mysql connection in two different sections of the code.
目前,我的PHP网站将在代码的两个不同部分中打开和关闭mysql连接。 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?
还是我应该停止懒惰,并尝试将所有代码都塞入一个打开的然后关闭的mysql连接中,而不是先打开再关闭,然后再打开和关闭mysql连接两次?
是的...它的效果...不会很大...但是会引起注意的..我是根据我的经验告诉您的...我已经做了两个网络门户....在两种情况下都没有连接顺序打开并强制处理。...结果是每次客户端请求必须发送到服务器并等待服务器响应...在这种情况下,如果您使用的是.net技术,则更喜欢使用数据集...因为它不需要每次都打开数据库连接并将其关闭....它只是将所需(查询的)数据库的副本保存在数据集中并执行操作...谢谢...
Opening and closing mysql connection is not a problem? 打开和关闭mysql连接不是问题吗? 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 有关更多信息,请参见此如何提高速度
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.