-
- Downloads
Add indexes and change SQL for expired artifacts to deal with artifacts migration efficiently
Artifacts are in the middle of being migrated from ci_builds to ci_job_artifacts. The expiration date is currently visible in both of these tables and the test for whether an expired artifact is present for a job is complex as it requires checking both the of the tables. Add two new indexes, one on ci_builds.artifacts_expire_at and one on ci_job_artifacts.expire_at to enable finding expired artifacts efficiently. And until the migration is finished, replace the SQL for finding expired and non-expired artifacts with a hand-crafted UNION ALL based query instead of using OR. This overcomes a database optimizer limitation that prevents it from using these indexes. When the migration is finished the next version should remove this query and replace it with a much simpler query on just ci_job_artifacts. See https://gitlab.com/gitlab-org/gitlab-ce/issues/42561 for followup.
Showing
- app/models/ci/build.rb 36 additions, 4 deletionsapp/models/ci/build.rb
- changelogs/unreleased/expired-ci-artifacts.yml 5 additions, 0 deletionschangelogs/unreleased/expired-ci-artifacts.yml
- db/migrate/20180119160751_optimize_ci_job_artifacts.rb 23 additions, 0 deletionsdb/migrate/20180119160751_optimize_ci_job_artifacts.rb
- db/schema.rb 2 additions, 0 deletionsdb/schema.rb
- spec/factories/ci/builds.rb 2 additions, 2 deletionsspec/factories/ci/builds.rb
Please register or sign in to comment