MySQL: Single or Multiple Connections?

孤人 提交于 2019-12-23 03:07:39

问题


I am developing a server application, which uses mysql for some data storing. Should I create a connection to the mysql on the server's start and use it for all queries, or create connection on each query? Which is better/faster?


回答1:


If you ask me, It's better to use only one connection, that way you can use session variables without any issues. Besides, with static variables, it's easy to permanently save the connection somewhere in the script.



来源:https://stackoverflow.com/questions/19345485/mysql-single-or-multiple-connections

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!