Commit 1961fd1f authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'ab-add-index-for-ci-builds-metrics' into 'master'

Create partial index for gitlab-monitor CI metrics

See merge request gitlab-org/gitlab-ce!32546
parents c5ecf106 bd56acd3
---
title: Create partial index for gitlab-monitor CI metrics
merge_request: 32546
author:
type: performance
# frozen_string_literal: true
class AddIndexForCiBuildsMetrics < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INDEX_NAME = 'ci_builds_gitlab_monitor_metrics'
def up
add_concurrent_index(:ci_builds, [:status, :created_at, :project_id], where: "type = 'Ci::Build'", name: INDEX_NAME)
end
def down
remove_concurrent_index_by_name(:ci_builds, INDEX_NAME)
end
end
......@@ -605,6 +605,7 @@ ActiveRecord::Schema.define(version: 2019_09_02_160015) do
t.index ["scheduled_at"], name: "partial_index_ci_builds_on_scheduled_at_with_scheduled_jobs", where: "((scheduled_at IS NOT NULL) AND ((type)::text = 'Ci::Build'::text) AND ((status)::text = 'scheduled'::text))"
t.index ["stage_id", "stage_idx"], name: "tmp_build_stage_position_index", where: "(stage_idx IS NOT NULL)"
t.index ["stage_id"], name: "index_ci_builds_on_stage_id"
t.index ["status", "created_at", "project_id"], name: "ci_builds_gitlab_monitor_metrics", where: "((type)::text = 'Ci::Build'::text)"
t.index ["status", "type", "runner_id"], name: "index_ci_builds_on_status_and_type_and_runner_id"
t.index ["token"], name: "index_ci_builds_on_token", unique: true
t.index ["token_encrypted"], name: "index_ci_builds_on_token_encrypted", unique: true, where: "(token_encrypted IS NOT NULL)"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment