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.