Route lookup optimization database calls
In [https://gitlab.com/gitlab-com/gl-infra/infrastructure/snippets/1875425](https://gitlab.com/gitlab-com/gl-infra/infrastructure/snippets/1875425#postgres-checkup_K003) the following two SQL queries account for more than 13% of all queries executed on GitLab.com:
```sql
SELECT "routes".\* FROM "routes"
WHERE "routes"."source_id" = ?
AND "routes"."source_type" = ?
LIMIT ?
```
```sql
SELECT "projects".\* FROM "projects"
INNER JOIN "routes" ON "routes"."source_id"
= "projects"."id" AND "routes"."source_type"
= ? WHERE ((LOWER(routes.path)
= LOWER(?))) ORDER BY (CASE WHEN
routes.path = ? THEN ? ELSE ?
END) LIMIT ?
```
Considering how much time we spend in these queries, is there more that we could do to optimize them or cache their results?
cc @abrandl
issue