Performance impact of not closing propel connection

陌路散爱 提交于 2019-12-12 04:20:22

问题


I'm using symfony 1.4/propel 1.4 for a project, which was made by other developer earlier. On that project, propel connection is taken by using following code

$con = Propel::getConnection(UsersPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);

However it never closes the connection using

Propel::close();

I just searched that there are 1500+ such incidents of opening connection & I guess none of them is closing connection.

I know its always good practice to close connection but in present case, it seems I wont be able to fix them all as fixing all the incidents is definitely going to take lot of time, may be a whole day. So now I'm confused if I should fix that or not. If I let it be like that, will it have any performance impact?

EDIT: Just for reference

Part 2 of this question Use of closing database connection in php


回答1:


If anything, explicitly closing connections may harm performance. PDO often caches connections from one request to the next, on the reasonable assumption that the next request will use the same credentials.

Edit: reading the docs, it looks to me like PDO::ATTR_PERSISTENT connections are cached regardless of any attempt to close them, so you might as well not bother.



来源:https://stackoverflow.com/questions/12365427/performance-impact-of-not-closing-propel-connection

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