PDO constructor very slow (mysql)
This bit of code is taking almost a half second to execute. Could somebody help me with some reasons this could be happening and some possible solutions?
If it matters, the DB is hosted by amazon rds
$this->_connection = new PDO(
$dsn,
$this->_config['username'],
$this->_config['password'开发者_开发问答],
$this->_config['driver_options']
);
PDO's constructor opens a database connection. When the DB is on a remote server, a half second (500ms) pause isn't too surprising, given ping times and the fact that you're not just opening a connection, but also logging in to it.
精彩评论