Commit a50fefb0 authored by Andreas Brandl's avatar Andreas Brandl

Merge branch 'ab/partial-events-index' into 'master'

Exclude null records from index on `events(group_id)`

See merge request gitlab-org/gitlab-ee!16619
parents 48298a0b 237c4784
---
title: Replace events index with partial one
merge_request: 32874
author:
type: performance
# frozen_string_literal: true
class ReplaceEventsIndexOnGroupIdWithPartialIndex < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index(:events, :group_id, where: 'group_id IS NOT NULL', name: 'index_events_on_group_id_partial')
remove_concurrent_index_by_name(:events, 'index_events_on_group_id')
end
def down
add_concurrent_index(:events, :group_id, name: 'index_events_on_group_id')
remove_concurrent_index_by_name(:events, 'index_events_on_group_id_partial')
end
end
......@@ -1330,7 +1330,7 @@ ActiveRecord::Schema.define(version: 2019_09_12_061145) do
t.index ["action"], name: "index_events_on_action"
t.index ["author_id", "project_id"], name: "index_events_on_author_id_and_project_id"
t.index ["created_at", "author_id"], name: "analytics_index_events_on_created_at_and_author_id"
t.index ["group_id"], name: "index_events_on_group_id"
t.index ["group_id"], name: "index_events_on_group_id_partial", where: "(group_id IS NOT NULL)"
t.index ["project_id", "created_at"], name: "index_events_on_project_id_and_created_at"
t.index ["project_id", "id"], name: "index_events_on_project_id_and_id"
t.index ["target_type", "target_id"], name: "index_events_on_target_type_and_target_id"
......
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