Use search service for project autocomplete
What does this MR do and why?
Autocomplete is slow for searching projects
and groups
. This is because these are doing global searches using database calls and on every call it has to compute current_user.authorized_projects
and current_user.authorized_groups
.
This MR changes the projects autocomplete from always using a database search to using the SearchService
which uses Elasticsearch if it's available which should be quicker.
The change is behind a feature flag: autocomplete_projects_use_search_service
Future
I'm thinking we can extend this to search over fewer fields (just project name, namespace name) which will be much faster and better aligned with autocomplete behaviour.
We can also cache heavy operations like determining a user's authorized projects and groups for a few minutes so that subsequent autocomplete and search calls are much faster. I think this will have the biggest impact on autocomplete slowness.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- Disable the feature flag:
Feature.disable(:autocomplete_projects_use_search_service)
- Perform an autocomplete: type
s
or/
in gitlab. Note the results - Enable the feature flag:
Feature.enable(:autocomplete_projects_use_search_service)
- Perform the same autocompletes and note the same results are returned
Related to #472011 (closed)