diff --git a/db/post_migrate/20231218074237_add_index_to_ci_job_artifact_states.rb b/db/post_migrate/20231218074237_add_index_to_ci_job_artifact_states.rb
new file mode 100644
index 0000000000000000000000000000000000000000..bd0a46f14ba223d7505fd2a2617f0269f5c947df
--- /dev/null
+++ b/db/post_migrate/20231218074237_add_index_to_ci_job_artifact_states.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddIndexToCiJobArtifactStates < Gitlab::Database::Migration[2.2]
+  milestone '16.8'
+  disable_ddl_transaction!
+  INDEX_NAME = :index_ci_job_artifact_states_on_job_artifact_id_partition_id
+  TABLE_NAME = :ci_job_artifact_states
+
+  def up
+    add_concurrent_index(TABLE_NAME, [:job_artifact_id, :partition_id], name: INDEX_NAME)
+  end
+
+  def down
+    remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME)
+  end
+end
diff --git a/db/post_migrate/20231218074508_add_index_to_ci_build_trace_metadata.rb b/db/post_migrate/20231218074508_add_index_to_ci_build_trace_metadata.rb
new file mode 100644
index 0000000000000000000000000000000000000000..574c71034feb7fc3135e5f2937fd64f99b8b3e66
--- /dev/null
+++ b/db/post_migrate/20231218074508_add_index_to_ci_build_trace_metadata.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class AddIndexToCiBuildTraceMetadata < Gitlab::Database::Migration[2.2]
+  milestone '16.8'
+  disable_ddl_transaction!
+  INDEX_NAME = :index_ci_build_trace_metadata_on_trace_artifact_id_partition_id
+  TABLE_NAME = :ci_build_trace_metadata
+
+  def up
+    add_concurrent_index(TABLE_NAME, [:trace_artifact_id, :partition_id], name: INDEX_NAME)
+  end
+
+  def down
+    remove_concurrent_index_by_name(TABLE_NAME, INDEX_NAME)
+  end
+end
diff --git a/db/schema_migrations/20231218074237 b/db/schema_migrations/20231218074237
new file mode 100644
index 0000000000000000000000000000000000000000..1e3b78d7eabd1925173f8423db1911da79b8d1ec
--- /dev/null
+++ b/db/schema_migrations/20231218074237
@@ -0,0 +1 @@
+ed7563aea9a1d9496813a07b88597592b1c11793ff4673727855d09be07c93b1
\ No newline at end of file
diff --git a/db/schema_migrations/20231218074508 b/db/schema_migrations/20231218074508
new file mode 100644
index 0000000000000000000000000000000000000000..d3ec5b303f56c35725f5f27e0af82e91e537f0c9
--- /dev/null
+++ b/db/schema_migrations/20231218074508
@@ -0,0 +1 @@
+0f97f218bdb2172c8abcb1a89e647bb0946867ab169d44d2736d24ed93e09322
\ No newline at end of file
diff --git a/db/structure.sql b/db/structure.sql
index d7226ae98c3b475597ec8e3bd9f5d67b84289348..8b7c6eb18b4f5721a7b8f6e5919a0e217f6ae834 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -32117,6 +32117,8 @@ CREATE UNIQUE INDEX index_ci_build_trace_metadata_on_partition_id_build_id ON ci
 
 CREATE INDEX index_ci_build_trace_metadata_on_trace_artifact_id ON ci_build_trace_metadata USING btree (trace_artifact_id);
 
+CREATE INDEX index_ci_build_trace_metadata_on_trace_artifact_id_partition_id ON ci_build_trace_metadata USING btree (trace_artifact_id, partition_id);
+
 CREATE INDEX p_ci_builds_metadata_build_id_idx ON ONLY p_ci_builds_metadata USING btree (build_id) WHERE (has_exposed_artifacts IS TRUE);
 
 CREATE INDEX index_ci_builds_metadata_on_build_id_and_has_exposed_artifacts ON ci_builds_metadata USING btree (build_id) WHERE (has_exposed_artifacts IS TRUE);
@@ -32233,6 +32235,8 @@ CREATE UNIQUE INDEX index_ci_instance_variables_on_key ON ci_instance_variables
 
 CREATE INDEX index_ci_job_artifact_states_on_job_artifact_id ON ci_job_artifact_states USING btree (job_artifact_id);
 
+CREATE INDEX index_ci_job_artifact_states_on_job_artifact_id_partition_id ON ci_job_artifact_states USING btree (job_artifact_id, partition_id);
+
 CREATE INDEX index_ci_job_artifacts_expire_at_unlocked_non_trace ON ci_job_artifacts USING btree (expire_at) WHERE ((locked = 0) AND (file_type <> 3) AND (expire_at IS NOT NULL));
 
 CREATE INDEX index_ci_job_artifacts_for_terraform_reports ON ci_job_artifacts USING btree (project_id, id) WHERE (file_type = 18);
diff --git a/spec/support/helpers/database/duplicate_indexes.yml b/spec/support/helpers/database/duplicate_indexes.yml
index ab9935a7a985afccd143b39e972963a3c7184007..cbb0b0be45712074633151b9d0fc80f44b00ce6b 100644
--- a/spec/support/helpers/database/duplicate_indexes.yml
+++ b/spec/support/helpers/database/duplicate_indexes.yml
@@ -27,6 +27,9 @@ boards_epic_board_recent_visits:
 boards_epic_user_preferences:
   index_boards_epic_user_preferences_on_board_user_epic_unique:
     - index_boards_epic_user_preferences_on_board_id
+ci_build_trace_metadata:
+  index_ci_build_trace_metadata_on_trace_artifact_id:
+    - index_ci_build_trace_metadata_on_trace_artifact_id_partition_id
 ci_job_artifacts:
   index_ci_job_artifacts_on_id_project_id_and_created_at:
     - index_ci_job_artifacts_on_project_id
@@ -34,6 +37,9 @@ ci_job_artifacts:
     - index_ci_job_artifacts_on_project_id
   index_ci_job_artifacts_on_project_id_and_id:
     - index_ci_job_artifacts_on_project_id
+ci_job_artifact_states:
+  index_ci_job_artifact_states_on_job_artifact_id:
+    - index_ci_job_artifact_states_on_job_artifact_id_partition_id
 ci_pipeline_artifacts:
   index_ci_pipeline_artifacts_on_pipeline_id_and_file_type:
     - index_ci_pipeline_artifacts_on_pipeline_id