这段代码需要几乎半秒的时间才能执行。有人可以帮我解决一些可能发生的原因以及一些可能的解决方案吗?

如果重要,数据库由amazon rds主持

        $this->_connection = new PDO(
            $dsn,
            $this->_config['username'],
            $this->_config['password'],
            $this->_config['driver_options']
        );
有帮助吗?

解决方案

PDO的构造函数打开数据库连接。当数据库位于远程服务器上时,半秒(500毫秒)暂停并不太令人惊讶,给定ping时间以及您不仅要打开连接而且还要登录到它的事实。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top