Commit 3e11d29f authored by Adam Hegyi's avatar Adam Hegyi

Add indexes to aggregated VSA tables

This change adds DB indexes to the new, aggregated value stream
analytics tables.

Changelog: added
parent e194c893
# frozen_string_literal: true
class AddIndexesToIssueStageEvents < Gitlab::Database::Migration[1.0]
include Gitlab::Database::PartitioningMigrationHelpers
disable_ddl_transaction!
GROUP_INDEX_NAME = 'index_issue_stage_events_group_duration'
GROUP_IN_PROGRESS_INDEX_NAME = 'index_issue_stage_events_group_in_progress_duration'
PROJECT_INDEX_NAME = 'index_issue_stage_events_project_duration'
PROJECT_IN_PROGRESS_INDEX_NAME = 'index_issue_stage_events_project_in_progress_duration'
def up
add_concurrent_partitioned_index :analytics_cycle_analytics_issue_stage_events,
'stage_event_hash_id, group_id, end_event_timestamp, issue_id, start_event_timestamp',
where: 'end_event_timestamp IS NOT NULL',
name: GROUP_INDEX_NAME
add_concurrent_partitioned_index :analytics_cycle_analytics_issue_stage_events,
'stage_event_hash_id, project_id, end_event_timestamp, issue_id, start_event_timestamp',
where: 'end_event_timestamp IS NOT NULL',
name: PROJECT_INDEX_NAME
add_concurrent_partitioned_index :analytics_cycle_analytics_issue_stage_events,
'stage_event_hash_id, group_id, start_event_timestamp, issue_id',
where: 'end_event_timestamp IS NULL AND state_id = 1',
name: GROUP_IN_PROGRESS_INDEX_NAME
add_concurrent_partitioned_index :analytics_cycle_analytics_issue_stage_events,
'stage_event_hash_id, project_id, start_event_timestamp, issue_id',
where: 'end_event_timestamp IS NULL AND state_id = 1',
name: PROJECT_IN_PROGRESS_INDEX_NAME
end
def down
remove_concurrent_partitioned_index_by_name :analytics_cycle_analytics_issue_stage_events, GROUP_INDEX_NAME
remove_concurrent_partitioned_index_by_name :analytics_cycle_analytics_issue_stage_events, PROJECT_INDEX_NAME
remove_concurrent_partitioned_index_by_name :analytics_cycle_analytics_issue_stage_events, GROUP_IN_PROGRESS_INDEX_NAME
remove_concurrent_partitioned_index_by_name :analytics_cycle_analytics_issue_stage_events, PROJECT_IN_PROGRESS_INDEX_NAME
end
end
# frozen_string_literal: true
class AddIndexesToMergeRequestStageEvents < Gitlab::Database::Migration[1.0]
include Gitlab::Database::PartitioningMigrationHelpers
disable_ddl_transaction!
GROUP_INDEX_NAME = 'index_merge_request_stage_events_group_duration'
GROUP_IN_PROGRESS_INDEX_NAME = 'index_merge_request_stage_events_group_in_progress_duration'
PROJECT_INDEX_NAME = 'index_merge_request_stage_events_project_duration'
PROJECT_IN_PROGRESS_INDEX_NAME = 'index_merge_request_stage_events_project_in_progress_duration'
def up
add_concurrent_partitioned_index :analytics_cycle_analytics_merge_request_stage_events,
'stage_event_hash_id, group_id, end_event_timestamp, merge_request_id, start_event_timestamp',
where: 'end_event_timestamp IS NOT NULL',
name: GROUP_INDEX_NAME
add_concurrent_partitioned_index :analytics_cycle_analytics_merge_request_stage_events,
'stage_event_hash_id, project_id, end_event_timestamp, merge_request_id, start_event_timestamp',
where: 'end_event_timestamp IS NOT NULL',
name: PROJECT_INDEX_NAME
add_concurrent_partitioned_index :analytics_cycle_analytics_merge_request_stage_events,
'stage_event_hash_id, group_id, start_event_timestamp, merge_request_id',
where: 'end_event_timestamp IS NULL AND state_id = 1',
name: GROUP_IN_PROGRESS_INDEX_NAME
add_concurrent_partitioned_index :analytics_cycle_analytics_merge_request_stage_events,
'stage_event_hash_id, project_id, start_event_timestamp, merge_request_id',
where: 'end_event_timestamp IS NULL AND state_id = 1',
name: PROJECT_IN_PROGRESS_INDEX_NAME
end
def down
remove_concurrent_partitioned_index_by_name :analytics_cycle_analytics_merge_request_stage_events, GROUP_INDEX_NAME
remove_concurrent_partitioned_index_by_name :analytics_cycle_analytics_merge_request_stage_events, PROJECT_INDEX_NAME
remove_concurrent_partitioned_index_by_name :analytics_cycle_analytics_merge_request_stage_events, GROUP_IN_PROGRESS_INDEX_NAME
remove_concurrent_partitioned_index_by_name :analytics_cycle_analytics_merge_request_stage_events, PROJECT_IN_PROGRESS_INDEX_NAME
end
end
f46a0dd662a80d38a4e8d3e6c4db05e61563a959b75d30a4c3724ae6afc2647f
\ No newline at end of file
08399bfbf62533c00dfe3ca3434f6be292ec768f053d3b1fde41d2d68de32fe7
\ No newline at end of file
This diff is collapsed.
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