php - mysql使用持久连接的目的和好处是什么?

标签 php mysql mysqli persistent-connection

根据php手册:

Persistent connections are not closed at the end of the script, but are cached and re-used when another script requests a connection using the same credentials. The persistent connection cache allows you to avoid the overhead of establishing a new connection every time a script needs to talk to a database, resulting in a faster web application.

一个优点是效率,我们不需要在每次脚本执行时都建立连接。持久连接的其他优点是什么?比如查询缓存等?

最佳答案

它允许跨多个请求恢复事务以及允许连接设置(例如字符集编码)持续存在

关于php - mysql使用持久连接的目的和好处是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44581377/

相关文章:

php - MySQLI - 对重复的多个用户进行插入或更新

mysql - EntityFramework 6 Alpha 2 & MySQL 连接器/NET 6.6.4

php - 在数据库表中没有行意味着出现错误 Undefined variable : results using codeigniter

php - mysql 使用 äüß 进行 json 编码

php - 获取 "Integrity constraint violation: 1048 Column ' payment_id' cannot be null"using Doctrine & Symfony

php - 在 PHP 中运行查询以显示在表中

php - 在 PHP 和 MySQL 方面需要帮助

php - 警告 : mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool 值在 ../第 7 行给出

php - INSERT 到 MYSQL 中,然后在关闭连接之前选择插入 id,然后将此 id 添加到其他 3 个表中

php - 使用 PHP SwiftMailer 和 SMTP 发送时事通讯