Commit 5ed9595e authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Add index to resource milestone events

This adds a conditional index to improve query performance in burnup
charts
parent 96369a9d
---
title: Add index to resource_milestone_events for add actions
merge_request: 37636
author:
type: other
# frozen_string_literal: true
class AddIndexToResourceMilestoneEventsAddEvents < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INDEX_NAME = 'index_resource_milestone_events_on_milestone_id_and_add_action'
ADD_ACTION = '1'
def up
# Index add milestone events
add_concurrent_index :resource_milestone_events, :milestone_id, where: "action = #{ADD_ACTION}", name: INDEX_NAME
end
def down
remove_concurrent_index :resource_milestone_events, :milestone_id, name: INDEX_NAME
end
end
5dc4cbfc6d7e79e5909e5250f382bc3c9fa4246b8f2aed81404899aee4eef81b
\ No newline at end of file
......@@ -20465,6 +20465,8 @@ CREATE INDEX index_resource_milestone_events_on_merge_request_id ON public.resou
CREATE INDEX index_resource_milestone_events_on_milestone_id ON public.resource_milestone_events USING btree (milestone_id);
CREATE INDEX index_resource_milestone_events_on_milestone_id_and_add_action ON public.resource_milestone_events USING btree (milestone_id) WHERE (action = 1);
CREATE INDEX index_resource_milestone_events_on_user_id ON public.resource_milestone_events USING btree (user_id);
CREATE INDEX index_resource_state_events_on_epic_id ON public.resource_state_events USING btree (epic_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