Improve handling of users with maintainer access to huge numbers of projects in terms of project runners

This issue is a follow-up from !194442 (comment 2643990042). Basically, we have users with maintainer access to tens of thousands of projects, of only which a small minority contain project runners. The current logic (behind the optimize_ci_owned_project_runners_query FF) does not handle that optimally given that the tables involved sit in 2 different databases.

An alternative could be to do a first pass on the ci_runner_projects table, by:

  1. searching for distinct project_ids in ci_runner_projects (query plan)
  2. checking which of these projects the user has maintainer+ access to (query plan)
  3. querying for the runners belonging to those projects (query plan).

This works for situations where there are only a few project runners and lots of projects (like the scenario linked above). We could even dynamically select the best approach by first checking if the count of projects associated with project runners is over a certain limit.

Edited by 🤖 GitLab Bot 🤖