From 1a3803effd42df628090b436b44a902482413e45 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Fri, 22 Dec 2023 07:37:08 +0800 Subject: [PATCH] improve possible performance bottleneck (#28547) (#28578) Backport #28547 by @lunny Replace #28500 Co-authored-by: Lunny Xiao --- models/issues/comment.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/models/issues/comment.go b/models/issues/comment.go index 9eaa8a6eba..f038d75eb3 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -1153,14 +1153,9 @@ func DeleteComment(ctx context.Context, comment *Comment) error { // UpdateCommentsMigrationsByType updates comments' migrations information via given git service type and original id and poster id func UpdateCommentsMigrationsByType(ctx context.Context, tp structs.GitServiceType, originalAuthorID string, posterID int64) error { _, err := db.GetEngine(ctx).Table("comment"). - Where(builder.In("issue_id", - builder.Select("issue.id"). - From("issue"). - InnerJoin("repository", "issue.repo_id = repository.id"). - Where(builder.Eq{ - "repository.original_service_type": tp, - }), - )). + Join("INNER", "issue", "issue.id = comment.issue_id"). + Join("INNER", "repository", "issue.repo_id = repository.id"). + Where("repository.original_service_type = ?", tp). And("comment.original_author_id = ?", originalAuthorID). Update(map[string]any{ "poster_id": posterID,