Question

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']
        );
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top