Skip to content

Add index on deployable_type/id for deployments

What does this MR do?

This index helps when we view job page, for job that performs deployment. We look for deployment made by our build.

It is visible here: https://gitlab.com/gitlab-com/www-gitlab-com/-/jobs/77501980.

This is the query in question that gets optimised by index: SELECT "deployments".* FROM "deployments" WHERE "deployments"."deployable_id" = 77501980 AND "deployments"."deployable_type" = 'CommitStatus' ORDER BY deployments.id DESC LIMIT 1. It uses STI and we don't have index on deployable_type and deployable_id.

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/48380

Edited by Yorick Peterse

Merge request reports

Loading