mr12086
mr12086

Reputation: 1147

Doctrine 1.2 Pager - Does it reduce the amount of data requested from the database

Something just crossed my mind, if i have a result set that is around the 1k mark just when I grab from the database.

If I use Doctrine(v1.2)_Pager limited to 25 per page. Does it reduce the amount of data pulled from the database to a mere 25. Or is it still grabbing the entire set and then reducing it?

Implemented as such:

$perPage = 25;
$numPageLinks = 25;

$pager = new Doctrine_Pager($q, $input->page, $perPage);

$result = $pager->execute(array(), Doctrine::HYDRATE_ARRAY);

$pagerRange = new Doctrine_Pager_Range_Sliding(
    array('chunk' => $numPageLinks), $pager
);

$pagerUrlBase = '...';

$pagerLayout = new Doctrine_Pager_Layout(
    $pager, $pagerRange, $pagerUrlBase);

$pagerLayout->setTemplate('...');
$pagerLayout->setSelectedTemplate(
    '...'
);
$pagerLayout->setSeparatorTemplate('...');

$this->view->records = $result;

Upvotes: 0

Views: 399

Answers (2)

Mike B
Mike B

Reputation: 32155

Doctrine's pager will only request 25 records.

You might be confusing it with something like Zend_Paginator_Array which takes a full array and trims it down depending on the configuration.

Upvotes: 2

Mike Purcell
Mike Purcell

Reputation: 19989

I recommend that you enable mysql query log, and tail the resulting log file. With it you can see the exact queries being issued for each request. As Mike B stated, Doctrine_Pager will issue a pagination query which will result in a limit, offset combination, but you may see other queries you didn't expect by tailing your query log file.

For example, while tailing the log file I was surprised to find that the Doctrine unlink methods were being duplicated. I still haven't figure out if it was Doctrine or Symfony issuing the duplicate delete queries, so I just wrote my own unlink which improved database/application performance.

Upvotes: 1

Related Questions