What are the disadvantages of using persistent connection in PDO?

Technology CommunityCategory: PHPWhat are the disadvantages of using persistent connection in PDO?
VietMX Staff asked 3 years ago

A common complain about persistent connections is that their state is not reset before reuse. For example, open and unfinished transactions are not automatically rolled back. If your script terminates unexpectedly in the middle of database operations, the next request that gets the left over connection will pick up where the dead script left off.

Persistent connections are a good idea only when it takes a (relatively) long time to connect to your database. Nowadays that’s almost never the case. Most modern databases (including PostgreSQL) have their own preferred ways of performing connection pooling that don’t have the immediate drawbacks that plain vanilla PHP-based persistent connections do.