Skip to content

Commit a23ccd2

Browse files
GiteaBotearl-warren
authored andcommitted
Speed up loading the dashboard on mysql/mariadb (go-gitea#28546) (go-gitea#28784)
Backport go-gitea#28546 by @lunny Fixes go-gitea#28155 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> (cherry picked from commit 6493085)
1 parent 70c7ee5 commit a23ccd2

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)