Skip to content

Optimize queries in "/projects/:id/share_locations" API endpoint

What does this MR do and why?

This MR improves the query performance for the api/v4/projects/:id/share_locations?search=search-term and api/v4/projects/:id/share_locations APIs, when accessed by a non-admin user.

For admin users, the query plan remains unchanged. (this is the query plan for admin users, which is quite OK in performance. Moreover, the probability of an admin using this API is less than a normal user using this API, so that is the area we focused on.)

SQL Query Plans:

Item Before After
non-admin user, without search term Plan Plan
non-admin user, with search term Plan Plan

We can see that the improvement in the case of "with search term" is massive, going down from mutiple seconds to milliseconds.

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.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Related to #393611 (closed)

Edited by Manoj M J

Merge request reports