我应该使用mysql持久连接吗? [英] Should i use mysql persistent connect?

查看:86
本文介绍了我应该使用mysql持久连接吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况是:我有一台运行LAMP的Debian服务器,一台虚拟主机和一个网站.我的MySQL在该网站上只有一个用户.

在这种情况下,我将从持久连接中受益吗?

无论如何,PHP文档似乎建议反对持久连接.

谢谢


是的,MySQL服务器在同一台计算机上.

解决方案

这里有一个讨论

如果您通过"localhost"进行连接,则连接将通过MySQL套接字自动建立,这反过来确实很便宜.

(群组链接取自 MySQL持久连接)

The situation is: I have one Debian Server running LAMP with one Virtual Host with one Website. My MySQL has only one user from that website.

In this case would I benefit from using a persistent connection?

The PHP documentation seems to advise against persistent connections in any case.

Thanks


Edit: Yes, the MySQL server is on the same machine.

解决方案

There's a discussion here http://groups.google.com/group/comp.databases.mysql/browse_thread/thread/4ae68befe1b488e7/e843f0b9e59ad710?#e843f0b9e59ad710 :

"No, it is not (better). Contrary, using mysql_pconnect() is considered harmful, as it tends to hog the MySQL server with idle connections."

If you connect via 'localhost', the connection will automatically be established via the MySQL socket, which is really cheap anyways.

(Groups link taken from MySQL Persistent Connections)

这篇关于我应该使用mysql持久连接吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆