mysqli persistent connection

前端 未结 3 794
暗喜
暗喜 2020-12-06 10:34

In short, is there some sort of mysqli_pconnect for high-usage PHP & MySQL servers, or do I need to stick with mysql

3条回答
  •  Happy的楠姐
    2020-12-06 11:35

    I don't bother with persistent connections in MySQL. Persistent connections are for databases like Oracle, in which making a new connection is much slower.

    In MySQL, making a connection is relatively fast (especially if you turn off reverse DNS lookups). There should be no need for persistent connections with MySQL. If your app is performance-critical, there are tons of things you can do with greater bang for your buck than worrying about persistent connections.

    Besides, persistent connections come with unintended side effects. If you use MySQL variables, temporary tables, change the character set of a connection, or forget to finish transactions, you could cause problems. For example, you could expose one user's private data to another user's PHP session because you leave a temporary table alive.

提交回复
热议问题