Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treeGetChildrenByIdAction has n+1 select issues #627

Closed
cancan101 opened this issue Jul 22, 2024 · 2 comments
Closed

treeGetChildrenByIdAction has n+1 select issues #627

cancan101 opened this issue Jul 22, 2024 · 2 comments
Assignees

Comments

@cancan101
Copy link
Contributor

Accessing treeGetChildrenByIdAction (/tree-get-children-by-id) exhibits n+1 select behavior:
Using data from Sentry:
image
The query handed to

protected function convertTagToArray(Tag $tag, bool $showSelection, array $assignedTagIds, bool $loadChildren = false, bool $recursiveChildren = false): array
{
$tagArray = [
'id' => $tag->getId(),
'text' => $tag->getName(),
'path' => $tag->getNamePath(),
'expandable' => $tag->hasChildren(),
'leaf' => !$tag->hasChildren(),
'iconCls' => 'pimcore_icon_element_tags',
'qtipCfg' => [
'title' => 'ID: ' . $tag->getId(),
],
];
if ($showSelection) {
$tagArray['checked'] = isset($assignedTagIds[$tag->getId()]);
}
if ($loadChildren) {
$children = $tag->getChildren();
$loadChildren = $recursiveChildren;
foreach ($children as $child) {
$tagArray['children'][] = $this->convertTagToArray($child, $showSelection, $assignedTagIds, $loadChildren, $recursiveChildren);
}
}
return $tagArray;
}

looks to load lazily. something like may address the issue: https://www.doctrine-project.org/projects/doctrine-orm/en/3.2/reference/working-with-objects.html#by-eager-loading

@kingjia90
Copy link
Contributor

Thank you for reporting!
I've opened 2 PRs that may help decreasing these queries, please see pimcore/pimcore#17390 and #629

Could you please apply the changes and re-run Sentry to see if there's an improvement? Thank you in advance

@kingjia90 kingjia90 self-assigned this Jul 24, 2024
@pimcore pimcore deleted a comment from github-actions bot Aug 14, 2024
@kingjia90
Copy link
Contributor

Marking this as done as the 2 PRs (pimcore/pimcore#17390 and #629) that might improve the behavior are merged

Let me know if you find anything else that we may improve or if it's not resolved and still occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants