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

[provisioning_api] Optimization for for large installations #17718

Closed
wants to merge 1 commit into from

Conversation

mikaelh
Copy link
Contributor

@mikaelh mikaelh commented Oct 28, 2019

Patch to optimize for large installations where subadmins have access to many groups (>250)

This fix reduces API calls to editUser (ex change locale/display name) from >2 minutes (!) to ~3 seconds per call in average in current installation.

Signed-off-by: Mikael Hammarin mikael@try2.se

… where subadmins have access to many of groups (>250)

- Current implementation in isUserAccessible() iterates over each group a subadmin is member of
- UsersController:editUser() calls isUserAccessible() even if the user is admin

This fix reduces API calls to editUser (ex change locale/display name) from >2 minutes (!) to ~3 seconds per call in average.

Signed-off-by: Mikael Hammarin <mikael@try2.se>
->andWhere($qb->expr()->eq('gm.uid', $qb->createNamedParameter($user->getUID())))
->setMaxResults(1)
->execute();
;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
;

@kesselb
Copy link
Contributor

kesselb commented Oct 28, 2019

Thanks for your patch 🎉

}
return false;

$qb = $this->dbConn->getQueryBuilder();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works with the default groups backend, so this is not possible. But I have another idea in mind to make this faster

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works with the default groups backend, so this is not possible. But I have another idea in mind to make this faster

Ah you are right. I did not think about that. If you point me in a direction I can look into it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supposedly, fetch the user's groups and check whether there is an overlap.

@@ -499,8 +499,8 @@ public function editUser(string $userId, string $key, string $value): DataRespon
} else {
// Check if admin / subadmin
$subAdminManager = $this->groupManager->getSubAdmin();
if ($subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)
|| $this->groupManager->isAdmin($currentLoggedInUser->getUID())) {
if ($this->groupManager->isAdmin($currentLoggedInUser->getUID())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice turn around 👍

This was referenced Dec 11, 2019
@blizzz
Copy link
Member

blizzz commented Dec 13, 2019

What's the state here?

@rullzer rullzer mentioned this pull request Dec 19, 2019
18 tasks
@rullzer rullzer modified the milestones: Nextcloud 18, Nextcloud 19 Dec 19, 2019
This was referenced Apr 4, 2020
This was referenced Apr 15, 2020
@rullzer rullzer mentioned this pull request Apr 23, 2020
11 tasks
@nickvergessen
Copy link
Member

Did a new PR in #20677

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

Successfully merging this pull request may close these issues.

None yet

5 participants