php pconnect 与 connect

发布于 2024-08-24 21:14:39 字数 140 浏览 4 评论 0原文

如果我有一个插入数据然后退出的脚本, 该脚本将被 100 个用户同时或在 2 分钟内打开。

(实际上我正在做电子邮件跟踪。)

所以 pconnect 更好,还是 connect 更好以减少资源?

插入后我已经关闭了。

If I have a script which inserts data then exits,
the script will be opened by 100 users at the same time or within 2 mins.

(Actually I'm doing email tracking.)

So pconnect is better, or connect is better to reduce the resource?

I have close when after insert.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

得不到的就毁灭 2024-08-31 21:14:40

mysql_pconnect() 将打开的连接放入池中,该池可供同一进程的任何其他请求使用。因此,每个工作人员都会保持连接打开,直到连接终止。如果您保持较低的工作线程数量,那么这是可以接受的,但是一旦增加了工作线程数量,那么您最好切换到 mysql_connect() 。每个请求需要的时间会稍长一些,因为每次都必须建立连接,但您只会创建与请求一样多的连接,而不是工作线程。

mysql_pconnect() drops the open connection into a pool that can be used by any other request to the same process. As such, each worker keeps the connection open until it dies. This can be acceptable if you keep the number of workers low, but as soon as you raise the number of workers then you're better off switching to mysql_connect(). It will take slightly longer per request since the connection has to be made each time, but you will only create as many connections as there are requests, not workers.

一页 2024-08-31 21:14:40

connect 使用较少的资源(Web 服务器的空闲实例不需要保持数据库连接打开),但 pconnect 稍快一些(不必打开新连接,它已经存在)。

connect uses fewer resources (idle instances of the web server don't need to keep a database connection open), but pconnect is slightly faster (don't have to open a new connection, it's already there).

余生再见 2024-08-31 21:14:40

您还可以查看此页面以获取更多信息

http://php.net/manual /en/function.mysql-pconnect.php

拿破仑

You can also check this page for more info

http://php.net/manual/en/function.mysql-pconnect.php

Napoleon

忆悲凉 2024-08-31 21:14:40

如果你使用 pconnect ,你将在 SLEEP 模式下有很多连接,这种脚本在 2 分钟内运行 100 次,你的 mysql 将死掉。

您可以使用 mysql_connect() 、 mysql_close()

If you use pconnect , you will have a lot of connections on SLEEP mode with this kind of script that runs 100 times in 2 minutes and your mysql will die.

You can use mysql_connect() , mysql_close()

独木成林 2024-08-31 21:14:40

mysql_pconnect() :与数据库永久连接。在进行此类操作时,您不能失去连接。

mysql_connect() :用于以正常方式连接数据库,使用一段时间,由于大量操作,您可能会失去连接。

我建议使用 mysql_pconnect() 进行数据库连接。

mysql_pconnect() : is permanent connection with database. you cant lose your connection while such kind of operation.

mysql_connect() : is for connect database with normal way using some time due to large number of operation you might lose your connection.

I suggest mysql_pconnect() for database connection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文