Skip to content

Commit 8a4c2ea

Browse files
committed
feat: add extra index to notification table
Index SQL: CREATE INDEX u_s_uu ON notification(user_id, status, updated_unix);
1 parent 0690cb0 commit 8a4c2ea

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

models/activities/notification.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"code.gitea.io/gitea/modules/timeutil"
1919

2020
"xorm.io/builder"
21+
"xorm.io/xorm/schemas"
2122
)
2223

2324
type (
@@ -71,6 +72,15 @@ type Notification struct {
7172
UpdatedUnix timeutil.TimeStamp `xorm:"updated INDEX NOT NULL"`
7273
}
7374

75+
// TableIndices implements xorm's TableIndices interface
76+
func (n *Notification) TableIndices() []*schemas.Index {
77+
usuuIndex := schemas.NewIndex("u_s_uu", schemas.IndexType)
78+
usuuIndex.AddColumn("user_id", "status", "updated_unix")
79+
indices := []*schemas.Index{usuuIndex}
80+
81+
return indices
82+
}
83+
7484
func init() {
7585
db.RegisterModel(new(Notification))
7686
}

0 commit comments

Comments
 (0)