3

According to php manual:

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.

One advantage is efficiency that we do not need to make connection each time script executes. What are other advantages of persistent connection? Like query cache etc?

waqas
  • 91
  • 8
  • [Mysql persistent connections and advantages of mysql_pconnect?](https://stackoverflow.com/q/1128329/6521116) – LF00 Jun 16 '17 at 05:26
  • Mostly the disadvantages are mentioned in most articles. According to php manual :" In fact, to be extremely clear about the subject, persistent connections don't give you any functionality that wasn't possible with their non-persistent brothers." – waqas Jun 16 '17 at 06:03
  • To reduce the delay caused by establishing connectivity between two servers by preventing the connection from closing and needing to be renegotiated. Such as when connected to a distant or heavily trafficked server. Otherwise none. – Will B. Jun 16 '17 at 06:31
  • It seems that it can only be used to reduce time consumed in establishing connection. I couldn't find any other benefit. – waqas Jun 16 '17 at 07:37
  • My earlier experiences (legacy mysql extension around the mid 2000's) were awful: PHP was actually unable to reuse existing connections, God knows why, and I eventually exhaused the connection limit. I hope that the mysqli in 2017 has fixed that. In any case, unlike with other database engines, MySQL connections happen really fast so potential benefit is not as promising. – Álvaro González Jul 05 '17 at 08:30

1 Answers1

1

it Allows for resumption of transactions across multiple request as well as Allow connections setting such as character set encoding to persist

  • Yes, may be it. https://stackoverflow.com/questions/2708237/php-mysql-transactions-examples https://stackoverflow.com/questions/24965761/working-with-mysqli-ini-set – Andrei Jul 05 '17 at 08:48