diff options
author | Giteabot <teabot@gitea.io> | 2024-01-15 10:01:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-15 02:01:25 +0000 |
commit | 6493085aeeb734a27052b9e998f452b6d649c103 (patch) | |
tree | d953e92a268387f6fd8a5f20009f8c0c750e970e | |
parent | fbf29f29b5225be8e5e682e45b6977e7dda9b318 (diff) | |
download | gitea-6493085aeeb734a27052b9e998f452b6d649c103.tar.gz gitea-6493085aeeb734a27052b9e998f452b6d649c103.zip |
Speed up loading the dashboard on mysql/mariadb (#28546) (#28784)
Backport #28546 by @lunny
Fixes #28155
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
-rw-r--r-- | models/activities/action.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/models/activities/action.go b/models/activities/action.go index bf56f27a8b..3c66b6876e 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) |