diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2018-11-19 15:39:15 +0100 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2019-01-03 15:12:49 +0100 |
commit | 50f9817afb3d6cc599c499abf1536215eada5600 (patch) | |
tree | b5b8aafba9c086e514d873ff15de7f7146725a82 /db/migrate | |
parent | a39cddf7b78f71006c7b8884432efe41220becb6 (diff) | |
download | gitlab-ce-50f9817afb3d6cc599c499abf1536215eada5600.tar.gz |
Add specific indexes for CI
This adds specific indexes to speed up the query mentioned in
https://gitlab.com/gitlab-org/gitlab-ce/issues/50763 and to avoid
statement timeouts.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/50763.
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb b/db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb new file mode 100644 index 00000000000..2134131b28f --- /dev/null +++ b/db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddIndexesToCiBuildsAndPipelines < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_pipelines, [:project_id, :ref, :id], order: { id: :desc } + add_concurrent_index :ci_builds, [:commit_id, :artifacts_expire_at, :id], where: "type = 'Ci::Build' AND (retried = false OR retried IS NULL) AND name IN ('sast', 'dependency_scanning', 'sast:container', 'container_scanning', 'dast')" + end + + def down + remove_concurrent_index :ci_pipelines, [:project_id, :ref, :id], order: { id: :desc } + remove_concurrent_index :ci_builds, [:commit_id, :artifacts_expire_at, :id], where: "type = 'Ci::Build' AND (retried = false OR retried IS NULL) AND name IN ('sast', 'dependency_scanning', 'sast:container', 'container_scanning', 'dast')" + end +end |