From a23ccd2d93c53c13d1e539016254ae154f63a247 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Mon, 15 Jan 2024 10:01:25 +0800 Subject: [PATCH] Speed up loading the dashboard on mysql/mariadb (#28546) (#28784) Backport #28546 by @lunny Fixes #28155 Co-authored-by: Lunny Xiao (cherry picked from commit 6493085aeeb734a27052b9e998f452b6d649c103) --- models/activities/action.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/models/activities/action.go b/models/activities/action.go index db35a8e5f7..fe1642641c 100644 --- a/models/activities/action.go +++ b/models/activities/action.go @@ -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)