1

我正在使用Zend 1.12数据库postgresql。我也在使用Zend_Db_Table_Abstract接口来访问我的数据库。

我的代码(简化):

class Application_Model_DbTable_Images extends Zend_Db_Table_Abstract
{
    protected $_name = 'images';

    public function getImage($id)
    {
        $row = $this->fetchRow("id = $id");
        return $row;
    }
}

然后我像这样使用它:

$db = new Application_Model_DbTable_Images();
$img = $db->getImage(10);

问题是这个调用时间太长了。在我的 pgAdmin 中,此查询需要 10-20 毫秒,但在 PHP 中,此查询需要 300-500 毫秒。我使用了 XDebug,跟踪调用堆栈,我了解到占用大部分时间(超过 90%)的函数是php::PDO->__construct. 我可以做些什么来减少我的查询持续时间?

4

0 回答 0