Fix indexes for project_repository_states
What does this MR do?
We currently have index
add_index "project_repository_states", ["project_id"], name: "idx_repository_states_outdated_checksums", where: "(((repository_verification_checksum IS NULL) AND (last_repository_verification_failure IS NULL)) OR ((wiki_verification_checksum IS NULL) AND (last_wiki_verification_failure IS NULL)))", using: :btree
which is not used when we use only wiki or repository related fields alone, like here:
SELECT COUNT(*) FROM "projects" INNER JOIN "project_repository_states" ON "project_repository_states"."project_id" = "projects"."id" WHERE ("project_repository_states"."repository_verification_checksum" IS NOT NULL) AND "project_repository_states"."last_repository_verification_failure" IS NULL;
I'm not deleting the old index yet as it's used in some queries. I think we need to defer it for the next release.
@yorickpeterse WDYT?
I only tested this on my local database which is not accurate at all. How can we EXPLAIN ANALYZE
it @yorickpeterse ?
Are there points in the code the reviewer needs to double check?
Why was this MR needed?
Screenshots (if relevant)
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
API support added -
Tests added for this feature/bug - Conform by the code review guidelines
-
Has been reviewed by a UX Designer -
Has been reviewed by a Frontend maintainer -
Has been reviewed by a Backend maintainer -
Has been reviewed by a Database specialist
-
-
EE specific content should be in the top level /ee
folder -
Conform by the merge request performance guides -
Conform by the style guides -
Conform by the database guides -
If you have multiple commits, please combine them into a few logically organized commits by squashing them -
Internationalization required/considered -
If paid feature, have we considered GitLab.com plan and how it works for groups and is there a design for promoting it to users who aren't on the correct plan -
End-to-end tests pass ( package-and-qa
manual pipeline job)
What are the relevant issue numbers?
Edited by Valery Sizov