Bug #102355
closedExtbase resolves all 1:n relations even though count indicates no releations
0%
Description
Extbases DataMapper resolves relations to other entities. 1:n relations usually store a relation count on the parent, so whenever it shows 0, it wouldn't be necessary to try to fetch relations. This saves 1 query per relation but in certain scenarios with many entities and relations this saves tons of superfluous db operations.
protected function fetchRelatedEager(DomainObjectInterface $parentObject, $propertyName, $fieldValue = '')
{
return $fieldValue === '' ? $this->getEmptyRelationValue($parentObject, $propertyName) : $this->getNonEmptyRelationValue($parentObject, $propertyName, $fieldValue);
}
This method already tries to be smart but it only sees empty strings as empty relation value.
Proposal: Expect the $fieldValue to hold an integer, cast other types to int and evaluate if said int is 0. https://3v4l.org/mqsvQ
Updated by Christian Kuhn 2 months ago
- Status changed from New to Rejected
Hey. I'm going to reject here: I have a quite strong opinion that we need to get rid of the "parent count" fields altogether: they are notoriously outdated and they have logic collisions in workspace scenarios where they can never have the 'correct' value. I worked a lot on sys_refindex in recent versions: this one allows to fetch relations of multiple rows and fields with one query, and we're starting to actively use it in the frontend since v13, and it has good test coverage, so it would be a possible solution switching to this instead.