Commit f13cebce authored by Tiger's avatar Tiger

Add clusters index to improve usage data queries

parent 7626fad2
---
title: Add clusters index to improve usage data queries
merge_request: 28626
author:
type: performance
# frozen_string_literal: true
class AddClusterTypeIndexToClusters < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
INDEX_NAME = 'index_clusters_on_enabled_cluster_type_id_and_created_at'
disable_ddl_transaction!
def up
add_concurrent_index :clusters, [:enabled, :cluster_type, :id, :created_at], name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :clusters, INDEX_NAME
end
end
......@@ -9079,6 +9079,8 @@ CREATE INDEX index_clusters_kubernetes_namespaces_on_project_id ON public.cluste
CREATE INDEX index_clusters_on_enabled_and_provider_type_and_id ON public.clusters USING btree (enabled, provider_type, id);
CREATE INDEX index_clusters_on_enabled_cluster_type_id_and_created_at ON public.clusters USING btree (enabled, cluster_type, id, created_at);
CREATE INDEX index_clusters_on_management_project_id ON public.clusters USING btree (management_project_id) WHERE (management_project_id IS NOT NULL);
CREATE INDEX index_clusters_on_user_id ON public.clusters USING btree (user_id);
......@@ -13200,6 +13202,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200331220930
20200401095430
20200401211005
20200402001106
20200402123926
20200402124802
20200402135250
......
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