The DefaultUserPickerSearchService builds a query that is very slow to run on instances with many users. It seems to run faster for searches on short usernames compared to searches on long usernames (e.g. a search for "b" runs much faster than a search for "bhas").
This causes features such as mentions to perform poorly on instances with many users (e.g. JAC).
This performance problem is more evident on instances with many users, such as JAC. For local testing, you can use the JIRA Data Generator Plugin to create many users (about 50,000 is necessary to start seeing a significant problem).
- Hit an endpoint which uses the user search service e.g. https://jira.atlassian.com/rest/api/2/user/viewissue/search?username=bhas&issueKey=JRA-59658
Response comes back in less than 100ms.
Response comes back in ~2.5s
DefaultUserPickerSearchService ends up creating the following query:
Where each LIKE is prepending a separator to the search query e.g. if you search for "Broo" it will create a LIKE for: " Broo", "-Broo", "(Broo" etc. This is so a search for "Broo" will return a user like "Mike Cannon-Brookes". The query above can be even worse if the search is also including results for users whose email address matches, as it will add another 8 LIKE clauses to the above query.
There is no workaround for this issue.