Не подтверждена Коммит c98e5d92 создал по автору Andreas Brandl's avatar Andreas Brandl
Просмотр файлов

Replace events index with partial one

This improves the index size by removing all records with `group_id`
from the index. On GitLab.com this means reducing the size from 9 GB to
8kb (as long as the column stays mostly null).

Relates to
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/32826#note_214690051
владелец 0844ec02
---
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
......@@ -1321,7 +1321,7 @@
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
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать