Skip to content

Commit

Permalink
Avoid unnecessary information in query hints to improve query cache h…
Browse files Browse the repository at this point in the history
…it ratio
  • Loading branch information
mpdude committed Jun 28, 2021
1 parent 73aa6e8 commit a45fcdf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Tools/Pagination/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function getIterator()
$ids = array_map('current', $foundIdRows);

$this->appendTreeWalker($whereInQuery, WhereInWalker::class);
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, count($ids));
$whereInQuery->setHint(WhereInWalker::HINT_PAGINATOR_ID_COUNT, (bool) $ids);
$whereInQuery->setFirstResult(null)->setMaxResults(null);
$whereInQuery->setParameter(WhereInWalker::PAGINATOR_ID_ALIAS, $ids);
$whereInQuery->setCacheable($this->query->isCacheable());
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ public function walkSelectStatement(SelectStatement $AST)
$pathExpression = new PathExpression(PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, $rootAlias, $identifierFieldName);
$pathExpression->type = $pathType;

$count = $this->_getQuery()->getHint(self::HINT_PAGINATOR_ID_COUNT);
$hasIds = $this->_getQuery()->getHint(self::HINT_PAGINATOR_ID_COUNT);

if ($count > 0) {
if ($hasIds) {
$arithmeticExpression = new ArithmeticExpression();
$arithmeticExpression->simpleArithmeticExpression = new SimpleArithmeticExpression(
[$pathExpression]
Expand Down

0 comments on commit a45fcdf

Please sign in to comment.