简体   繁体   English

Doctrine 1.2 Pager-它是否减少了从数据库请求的数据量

[英]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. 如果我刚从数据库中抓取到一个结果集时,其结果集大约在1k标记之内,那件事就让我有些不解。

If I use Doctrine(v1.2)_Pager limited to 25 per page. 如果我使用Doctrine(v1.2)_Pager限制为每页25个。 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? 它会将从数据库中提取的数据量减少到仅25个吗?还是仍然抢着整个数据集然后减少呢?

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. 教义的传呼机将仅请求25条记录。

You might be confusing it with something like Zend_Paginator_Array which takes a full array and trims it down depending on the configuration. 您可能会将其与Zend_Paginator_Array东西混淆,后者会使用完整的数组并根据配置对其进行修整。

I recommend that you enable mysql query log , and tail the resulting log file. 我建议您启用mysql query log ,并尾随生成的日志文件。 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. 如Mike B所述, Doctrine_Pager将发出分页查询,这将导致限制,偏移量组合,但是通过尾随查询日志文件,您可能会看到其他您不期望的查询。

For example, while tailing the log file I was surprised to find that the Doctrine unlink methods were being duplicated. 例如,在尾随日志文件时,我惊讶地发现Doctrine unlink方法被复制了。 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. 我仍然不知道是Doctrine还是Symfony发出重复的删除查询,所以我只是编写了自己的取消链接,从而提高了数据库/应用程序的性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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