简体   繁体   中英

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;

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM