Faster user repos listing
Created by: tsenart
This PR denormalizes the namespace_user_id in external_services, by adding it to external_service_repos too. As described in https://github.com/sourcegraph/sourcegraph/issues/19561#issuecomment-811031184, avoiding the join with external services should completely bypass the problem.
- Here's the new plan: https://explain.dalibo.com/plan/ZfB
- And the old plan: https://explain.dalibo.com/plan/7zc
@ryanslade @asdine: I chose to fill in the user_id via SQL join with external_services in the queries, instead of passing that value in from application code. The change would be much larger if we did that change in application code, and I didn't feel comfortable with it. Maybe we should do it though? This "Sources" code is a bit hard to reason about, compared to the database schema itself.
Fixes #19561 (closed)