diff --git a/db/post_migrate/20240624053511_extend_uploads_index.rb b/db/post_migrate/20240624053511_extend_uploads_index.rb new file mode 100644 index 0000000000000000000000000000000000000000..87d37bdaf84bbc75aa92348fa4e4326536fac898 --- /dev/null +++ b/db/post_migrate/20240624053511_extend_uploads_index.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class ExtendUploadsIndex < Gitlab::Database::Migration[2.2] + milestone '17.2' + disable_ddl_transaction! + + INDEX_NAME = 'index_uploads_on_model_id_model_type_uploader_created_at' + + def up + add_concurrent_index :uploads, [:model_id, :model_type, :uploader, :created_at], name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :uploads, INDEX_NAME + end +end diff --git a/db/post_migrate/20240624053957_remove_redundant_uploads_index.rb b/db/post_migrate/20240624053957_remove_redundant_uploads_index.rb new file mode 100644 index 0000000000000000000000000000000000000000..307b5ef0e91d7efa4c84bf1eaa2aff4b8e69da15 --- /dev/null +++ b/db/post_migrate/20240624053957_remove_redundant_uploads_index.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class RemoveRedundantUploadsIndex < Gitlab::Database::Migration[2.2] + milestone '17.2' + disable_ddl_transaction! + + INDEX_NAME = 'index_uploads_on_model_id_and_model_type' + + def up + remove_concurrent_index_by_name :uploads, INDEX_NAME + end + + def down + add_concurrent_index :uploads, [:model_id, :model_type], name: INDEX_NAME + end +end diff --git a/db/schema_migrations/20240624053511 b/db/schema_migrations/20240624053511 new file mode 100644 index 0000000000000000000000000000000000000000..3cd3c6f4d0df49ebfc05728d501cf448d3e6322c --- /dev/null +++ b/db/schema_migrations/20240624053511 @@ -0,0 +1 @@ +747c129e2217119db23897f97146a164a3471717ccd35566fdac038dba4e2132 \ No newline at end of file diff --git a/db/schema_migrations/20240624053957 b/db/schema_migrations/20240624053957 new file mode 100644 index 0000000000000000000000000000000000000000..b440a10db6f7b6d7ec1805f65ac4beaf22d6727f --- /dev/null +++ b/db/schema_migrations/20240624053957 @@ -0,0 +1 @@ +a8082990cc636c0dfe1b321df447506eef3399eb148da5e5d496150b37165ed2 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index ba3789cbe6d8c90b647fe92a1682b4e6de4bdea9..5c4addcbd858e9c8ba86ee7d25b3ce710acfdbfd 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -29254,7 +29254,7 @@ CREATE INDEX index_upload_states_pending_verification ON upload_states USING btr CREATE INDEX index_uploads_on_checksum ON uploads USING btree (checksum); -CREATE INDEX index_uploads_on_model_id_and_model_type ON uploads USING btree (model_id, model_type); +CREATE INDEX index_uploads_on_model_id_model_type_uploader_created_at ON uploads USING btree (model_id, model_type, uploader, created_at); CREATE INDEX index_uploads_on_store ON uploads USING btree (store);