diff --git a/models/issues/comment.go b/models/issues/comment.go
index 66b3a8527f..8b1b18051e 100644
--- a/models/issues/comment.go
+++ b/models/issues/comment.go
@@ -246,7 +246,7 @@ type Comment struct {
 	NewTitle         string
 	OldRef           string
 	NewRef           string
-	DependentIssueID int64
+	DependentIssueID int64  `xorm:"index"` // This is used by issue_service.deleteIssue
 	DependentIssue   *Issue `xorm:"-"`
 
 	CommitID        int64
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go
index 38fff37bed..4527bcc1ae 100644
--- a/models/migrations/migrations.go
+++ b/models/migrations/migrations.go
@@ -536,6 +536,8 @@ var migrations = []Migration{
 	NewMigration("Add RemoteAddress to mirrors", v1_21.AddRemoteAddressToMirrors),
 	// v277 -> v278
 	NewMigration("Add Index to issue_user.issue_id", v1_21.AddIndexToIssueUserIssueID),
+	// v278 -> v279
+	NewMigration("Add Index to comment.dependent_issue_id", v1_21.AddIndexToCommentDependentIssueID),
 }
 
 // GetCurrentDBVersion returns the current db version
diff --git a/models/migrations/v1_21/v278.go b/models/migrations/v1_21/v278.go
new file mode 100644
index 0000000000..d6a462d1e7
--- /dev/null
+++ b/models/migrations/v1_21/v278.go
@@ -0,0 +1,16 @@
+// Copyright 2023 The Gitea Authors. All rights reserved.
+// SPDX-License-Identifier: MIT
+
+package v1_21 //nolint
+
+import (
+	"xorm.io/xorm"
+)
+
+func AddIndexToCommentDependentIssueID(x *xorm.Engine) error {
+	type Comment struct {
+		DependentIssueID int64 `xorm:"index"`
+	}
+
+	return x.Sync(new(Comment))
+}