Patch #44190
openImprove @mention performance by limiting initial suggestions
Description
When typing @ for user mentions without entering any search query, Redmine currently retrieves and returns all mentionable users in the project.
This becomes very slow on projects with many members. For example, in a project with about 4000 users, the autocomplete request takes more than 3 seconds every time @ is entered. This can degrade the user experience on Redmine instances with many users and increase server load.
This patch improves @mention autocomplete performance by limiting the initial suggestions, when the query is blank, to 100 users.
The full list is rarely useful for large projects because selecting a user from hundreds or thousands of users is difficult. However, showing initial suggestions can still be useful for small projects, so this patch keeps the existing behavior but limits the number of returned users.
Search with a query is unchanged. It already returns up to 10 users.
Benchmark:
Environment: production, project with about 4000 users.
Before:
Completed 200 OK in 3070ms (Views: 1.5ms | ActiveRecord: 261.8ms (8012 queries, 0 cached) | GC: 368.3ms)
After:
Completed 200 OK in 103ms (Views: 0.1ms | ActiveRecord: 13.0ms (208 queries, 0 cached) | GC: 3.9ms)
Files