Skip to content

Commit 8f32825

Browse files
lunnysilverwind
authored andcommitted
Speed up loading the dashboard on mysql/mariadb (go-gitea#28546)
Fixes go-gitea#28155
1 parent 04593ec commit 8f32825

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

models/activities/action.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,12 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
446446
return nil, 0, err
447447
}
448448

449-
sess := db.GetEngine(ctx).Where(cond).
450-
Select("`action`.*"). // this line will avoid select other joined table's columns
451-
Join("INNER", "repository", "`repository`.id = `action`.repo_id")
449+
sess := db.GetEngine(ctx).Where(cond)
450+
if setting.Database.Type.IsMySQL() {
451+
sess = sess.IndexHint("USE", "JOIN", "IDX_action_c_u_d")
452+
}
453+
sess = sess.Select("`action`.*"). // this line will avoid select other joined table's columns
454+
Join("INNER", "repository", "`repository`.id = `action`.repo_id")
452455

453456
opts.SetDefaultValues()
454457
sess = db.SetSessionPagination(sess, &opts)

0 commit comments

Comments
 (0)