summaryrefslogtreecommitdiffstats
path: root/models/migrations
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-03-12 15:23:44 +0800
committerGitHub <noreply@github.com>2024-03-12 07:23:44 +0000
commitd8bd6f34f09bc9a6602bebb33bdc9e1f255a0d7c (patch)
tree1536b715fb816410535893e7ba10279d89119638 /models/migrations
parentaed3b53abdd02a3ffbf9e8eb90272ff567333073 (diff)
downloadgitea-d8bd6f34f09bc9a6602bebb33bdc9e1f255a0d7c.tar.gz
gitea-d8bd6f34f09bc9a6602bebb33bdc9e1f255a0d7c.zip
Do some performance optimize for issues list and view issue/pull (#29515)
This PR do some performance optimzations. - [x] Add `index` for the column `comment_id` of `Attachment` table to accelerate query from the database. - [x] Remove unnecessary database queries when viewing issues. Before some conditions which id = 0 will be sent to the database - [x] Remove duplicated load posters - [x] Batch loading attachements, isread of comments on viewing issue --------- Co-authored-by: Zettat123 <zettat123@gmail.com>
Diffstat (limited to 'models/migrations')
-rw-r--r--models/migrations/migrations.go2
-rw-r--r--models/migrations/v1_22/v291.go14
2 files changed, 16 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go
index ce77432db4..87fddefb88 100644
--- a/models/migrations/migrations.go
+++ b/models/migrations/migrations.go
@@ -566,6 +566,8 @@ var migrations = []Migration{
NewMigration("Add default_wiki_branch to repository table", v1_22.AddDefaultWikiBranch),
// v290 -> v291
NewMigration("Add PayloadVersion to HookTask", v1_22.AddPayloadVersionToHookTaskTable),
+ // v291 -> v292
+ NewMigration("Add Index to attachment.comment_id", v1_22.AddCommentIDIndexofAttachment),
}
// GetCurrentDBVersion returns the current db version
diff --git a/models/migrations/v1_22/v291.go b/models/migrations/v1_22/v291.go
new file mode 100644
index 0000000000..0bfffe5d05
--- /dev/null
+++ b/models/migrations/v1_22/v291.go
@@ -0,0 +1,14 @@
+// Copyright 2024 The Gitea Authors. All rights reserved.
+// SPDX-License-Identifier: MIT
+
+package v1_22 //nolint
+
+import "xorm.io/xorm"
+
+func AddCommentIDIndexofAttachment(x *xorm.Engine) error {
+ type Attachment struct {
+ CommentID int64 `xorm:"INDEX"`
+ }
+
+ return x.Sync(&Attachment{})
+}