Actions
Bug #67837
closedExtbase performs unnecessary count queries
Status:
Closed
Priority:
Should have
Assignee:
Category:
Extbase
Target version:
Start date:
2015-06-30
Due date:
% Done:
100%
Estimated time:
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.
Actions