Move last_repository_updated_at to project_repositories
In https://gitlab.com/gitlab-com/gitlab-OKRs/-/work_items/7859 we have identified a number of queries that generate extreme amounts of WAL in the database. This issue deals with the query:
"UPDATE
""projects""
SET
""updated_at"" = $ 1,
""last_repository_updated_at"" = $ 2
WHERE
""projects"".""id"" = $ 3
AND (
last_repository_updated_at < $ 4
OR last_repository_updated_at IS NULL
)"
We will move last_repository_updated_at
off the projects
table and onto the project_repositories
table.
Implementation guide:
- Create new column and index on
project_repositories
- Write to both
projects
andproject_repositories
columns - Remove
projects
column and corresponding code