Bug #67837

Extbase performs unnecessary count queries

Added by Mathias Brodala over 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Should have
Category:
Extbase
Target version:
Start date:
2015-06-30
Due date:
% Done:

100%

TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Quoting from https://jira.neos.io/browse/FLOW-326:

QueryResult::count() always execute a COUNT query, even if the results have been fetched or counted already.
This is especially an issue because we make use of this method a lot under the hood.
For example this (simplified but realistic) Fluid snippet:

<f:if condition="{products}">
  <h1>{products -> f:count()} products:</h1>
  <f:widget.paginate objects="{products}" as="paginatedProducts">
    <ul>
      <f:for each="{paginatedProducts}" as="product" iteration="iteration">
        <li>{product.name}</li>
      </f:for>
    </ul>
  </f:widget.paginate>
</f:if>

will execute the same SELECT COUNT(DISTINCT ... query four times.
And those counts can be very costly especially with complex queries or many rows in a INNODB table.

Associated revisions

Revision 4cd7c504 (diff)
Added by Mathias Brodala over 4 years ago

[BUGFIX] 1st level cache for ``QueryResult::count()``

Counting the results of the ``QueryResultInterface`` proxy returned by
Repository finder methods always executed a ``COUNT query`` even if
the results had been fetched or counted already.

With this patch the number of results is cached as soon as the result
is initialized and/or counted once.

Resolves: #67837
Releases: master, 6.2
Change-Id: I98f680372b845f992ad3d436647b0cf5e460b606
Reviewed-on: http://review.typo3.org/40750
Reviewed-by: Stephan GroƟberndt <>
Reviewed-by: Wouter Wolters <>
Tested-by: Wouter Wolters <>
Reviewed-by: Markus Klein <>
Tested-by: Markus Klein <>

Revision 603edc3f (diff)
Added by Mathias Brodala over 4 years ago

[BUGFIX] 1st level cache for ``QueryResult::count()``

Counting the results of the ``QueryResultInterface`` proxy returned by
Repository finder methods always executed a ``COUNT query`` even if
the results had been fetched or counted already.

With this patch the number of results is cached as soon as the result
is initialized and/or counted once.

Resolves: #67837
Releases: master, 6.2
Change-Id: I98f680372b845f992ad3d436647b0cf5e460b606
Reviewed-on: http://review.typo3.org/40778
Reviewed-by: Markus Klein <>
Tested-by: Markus Klein <>

History

#1 Updated by Gerrit Code Review over 4 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/40750

#2 Updated by Gerrit Code Review over 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/40750

#3 Updated by Gerrit Code Review over 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/40750

#4 Updated by Gerrit Code Review over 4 years ago

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/40778

#5 Updated by Mathias Brodala over 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 50 to 100

#6 Updated by Benni Mack about 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF