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

Manually search for displayname by iterating over group members #27531

Closed
wants to merge 1 commit into from

Conversation

juliushaertl
Copy link
Member

I encountered that searching for displaynames within a group is quite bad performance wise as the it basically performs inGroup check for all users. A possible alternative would be to manually get the group users and do the filtering on the displayname manually. In my understanding this should give the same results at least as the database backend which just does an ILIKE '%search%' wich no placeholder support in the search term itself. @blizzz Do you see any issues with that for LDAP for example or in general?

Especially with large user directories and groupfolders with multiple groups assigned this could bring quite a performance boost, compared to the previous one when searching for those users (see example comparison for the groupfolder user search https://blackfire.io/profiles/compare/1baf5c45-af1f-42c1-99c2-0c8be6eb777e/graph)

@solracsf solracsf added the 2. developing Work in progress label Jul 1, 2021
@juliushaertl juliushaertl requested review from come-nc, blizzz, a team and skjnldsv and removed request for a team October 14, 2022 12:31
@juliushaertl juliushaertl added 3. to review Waiting for reviews performance 🚀 and removed 2. developing Work in progress labels Oct 14, 2022
@juliushaertl
Copy link
Member Author

The only backend I found when checking again that does not support search would be guests:

https://github.com/nextcloud/guests/blob/99f481bb1d87df5c0dd850fb090a38e6f361f2a3/lib/GroupBackend.php#L143

@juliushaertl juliushaertl marked this pull request as ready for review October 14, 2022 12:34
@juliushaertl juliushaertl added this to the Nextcloud 26 milestone Oct 14, 2022
@come-nc
Copy link
Contributor

come-nc commented Oct 17, 2022

The only backend I found when checking again that does not support search would be guests:

https://github.com/nextcloud/guests/blob/99f481bb1d87df5c0dd850fb090a38e6f361f2a3/lib/GroupBackend.php#L143

Should we add it there and/or make it mandatory for group backends to support? Maybe we can provide a fallback in ABackend calling usersInGroup and filtering.

@come-nc
Copy link
Contributor

come-nc commented Oct 17, 2022

@juliushaertl This is supplanted by #32866 no?

@juliushaertl
Copy link
Member Author

Still seems like a separate optimization as the search call over all groups with displayNamesInGroup is not touched in #32866

But I'd say this should be base on the new searchInGroup method then with the ISearchableGroupBackend.php interface

@blizzz blizzz mentioned this pull request Feb 1, 2023
This was referenced May 3, 2023
@blizzz blizzz mentioned this pull request May 17, 2023
@blizzz blizzz modified the milestones: Nextcloud 27, Nextcloud 28 May 23, 2023
@skjnldsv skjnldsv mentioned this pull request Nov 1, 2023
This was referenced Nov 6, 2023
@blizzz blizzz mentioned this pull request Nov 14, 2023
Signed-off-by: Julius Härtl <jus@bitgrid.net>
@skjnldsv skjnldsv requested review from a team, sorbaugh and Altahrim and removed request for a team February 27, 2024 17:44
foreach ($filteredUsers as $filteredUser) {
if ($group->inGroup($filteredUser)) {
$groupUsers[] = $filteredUser;
$userChunk = $group->searchUsers('', $chunkLimit, $chunkOffset);
Copy link
Collaborator

Choose a reason for hiding this comment

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

As I understand it, searchUsers allows to filter by uid and display name.
I guess we could filter a bit with it:

Suggested change
$userChunk = $group->searchUsers('', $chunkLimit, $chunkOffset);
$userChunk = $group->searchUsers($search, $chunkLimit, $chunkOffset);

This was referenced Mar 12, 2024
This was referenced Mar 20, 2024
@skjnldsv skjnldsv mentioned this pull request Mar 28, 2024
81 tasks
@skjnldsv skjnldsv modified the milestones: Nextcloud 29, Nextcloud 30 Mar 28, 2024
@come-nc come-nc removed their request for review June 17, 2024 15:35
This was referenced Jul 30, 2024
This was referenced Aug 5, 2024
@skjnldsv skjnldsv mentioned this pull request Aug 13, 2024
@skjnldsv skjnldsv closed this Aug 14, 2024
@skjnldsv skjnldsv removed this from the Nextcloud 31 milestone Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants