diff --git a/db/post_migrate/20250204075753_add_indexes_to_web_hook_logs_daily.rb b/db/post_migrate/20250204075753_add_indexes_to_web_hook_logs_daily.rb new file mode 100644 index 0000000000000000000000000000000000000000..199184fc085bfdbf6afc4ee3b1f931ff4915caad --- /dev/null +++ b/db/post_migrate/20250204075753_add_indexes_to_web_hook_logs_daily.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class AddIndexesToWebHookLogsDaily < Gitlab::Database::Migration[2.2] + include Gitlab::Database::PartitioningMigrationHelpers + + milestone '17.9' + disable_ddl_transaction! + + TABLE_NAME = :web_hook_logs_daily + INDEX_NAME_1 = :index_web_hook_logs_daily_on_web_hook_id_and_created_at + INDEX_NAME_2 = :index_web_hook_logs_daily_part_on_created_at_and_web_hook_id + COLUMN_NAMES_1 = [:web_hook_id, :created_at] + COLUMN_NAMES_2 = [:created_at, :web_hook_id] + + def up + add_concurrent_partitioned_index(TABLE_NAME, COLUMN_NAMES_1, name: INDEX_NAME_1) + add_concurrent_partitioned_index(TABLE_NAME, COLUMN_NAMES_2, name: INDEX_NAME_2) + end + + def down + remove_concurrent_partitioned_index_by_name(TABLE_NAME, INDEX_NAME_1) + remove_concurrent_partitioned_index_by_name(TABLE_NAME, INDEX_NAME_2) + end +end diff --git a/db/schema_migrations/20250204075753 b/db/schema_migrations/20250204075753 new file mode 100644 index 0000000000000000000000000000000000000000..e39ba52f11462c2803018ea6b363e7f0551aead1 --- /dev/null +++ b/db/schema_migrations/20250204075753 @@ -0,0 +1 @@ +e9d4029eddfd13d690662d2db1d322eef1deea13744948e5839671ab21fbc80e \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 6b3ee875a559102082286f7bd7c09c2fa627d3b5..58e7e2393f5a59b0b0293e8a92c5be55c372bfc6 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -34965,6 +34965,10 @@ CREATE UNIQUE INDEX index_vulns_user_mentions_on_vulnerability_id ON vulnerabili CREATE UNIQUE INDEX index_vulns_user_mentions_on_vulnerability_id_and_note_id ON vulnerability_user_mentions USING btree (vulnerability_id, note_id); +CREATE INDEX index_web_hook_logs_daily_on_web_hook_id_and_created_at ON ONLY web_hook_logs_daily USING btree (web_hook_id, created_at); + +CREATE INDEX index_web_hook_logs_daily_part_on_created_at_and_web_hook_id ON ONLY web_hook_logs_daily USING btree (created_at, web_hook_id); + CREATE INDEX index_web_hook_logs_on_web_hook_id_and_created_at ON ONLY web_hook_logs USING btree (web_hook_id, created_at); CREATE INDEX index_web_hook_logs_part_on_created_at_and_web_hook_id ON ONLY web_hook_logs USING btree (created_at, web_hook_id);