Speed up loading the dashboard on mysql/mariadb (#28546) (#28784)

Backport #28546 by @lunny

Fixes #28155

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
(cherry picked from commit 6493085aeeb734a27052b9e998f452b6d649c103)
This commit is contained in:
Giteabot 2024-01-15 10:01:25 +08:00 committed by Earl Warren
parent 70c7ee5475
commit a23ccd2d93
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -446,9 +446,12 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
return nil, 0, err
}
sess := db.GetEngine(ctx).Where(cond).
Select("`action`.*"). // this line will avoid select other joined table's columns
Join("INNER", "repository", "`repository`.id = `action`.repo_id")
sess := db.GetEngine(ctx).Where(cond)
if setting.Database.Type.IsMySQL() {
sess = sess.IndexHint("USE", "JOIN", "IDX_action_c_u_d")
}
sess = sess.Select("`action`.*"). // this line will avoid select other joined table's columns
Join("INNER", "repository", "`repository`.id = `action`.repo_id")
opts.SetDefaultValues()
sess = db.SetSessionPagination(sess, &opts)