Slow postgresql queries in Zend

2019-07-25 01:01发布

I am using Zend 1.12 with postgresql database. I am also using Zend_Db_Table_Abstract interface for accessing my database.

My code (simplified):

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

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

Then I use it like this:

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

The thing is that this call takes just too long. In my pgAdmin this query takes something like 10-20ms but in PHP this query takes 300-500ms. I used XDebug, followed call stack and I learned that the function that takes the most of this time (over 90%) is php::PDO->__construct. What can I do to decrease my query duration?

0条回答
登录 后发表回答