Consider ways to reduce lock-contention on the internal_ids table

According to our Top-50 Queries by total_time report (https://gitlab.com/gitlab-com/gl-infra/infrastructure/snippets/1880192), the number one query, at 13% of the total time, by queries sampled on the postgres primary of GitLab.com, during the sample period was:

SELECT  "internal_ids".* FROM "internal_ids" WHERE "internal_ids"."id" = ? LIMIT ? FOR UPDATE

My understanding (which could be wrong) is this is lock contention on the internal_ids table, which could be leading to performance degradation.

Several other issues have been written regarding this:

I'm creating this issue in this tracker, so that we can track this in the Infra/Dev board: https://gitlab.com/groups/gitlab-org/-/boards/1193197

cc @abrandl

Edited by Andrew Newdigate