Fix timeouts in group autocomplete query
What does this MR do and why?
When fix_user_authorized_groups
is enabled, the autocomplete query can
result in a bad query plan where PG does an index scan on the routes
table.
We fix this by wrapping the groups in a materialized CTE which then gets filtered by the route pattern.
Queries
- Old: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/32239/commands/99632
- New: https://postgres.ai/console/gitlab/gitlab-production-main/sessions/32239/commands/99631
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.
Related to #482866 (closed)
Edited by Heinrich Lee Yu