mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 17:52:45 +08:00
PERF: Add index_reply_id_on_post_replies
.
Speeds up the reference posts query in `Email::Sender#send`.
This commit is contained in:
parent
bfdd0fe64c
commit
bac1bcc79f
@ -0,0 +1,5 @@
|
||||
class AddIndexReplyIdOnPostReplies < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_index :post_replies, :reply_id
|
||||
end
|
||||
end
|
@ -110,7 +110,8 @@ module Email
|
||||
"<topic/#{topic_id}/#{post_id}@#{host}>"
|
||||
|
||||
referenced_posts = Post.includes(:incoming_email)
|
||||
.where(id: PostReply.where(reply_id: post_id).select(:post_id))
|
||||
.joins("INNER JOIN post_replies ON post_replies.post_id = posts.id ")
|
||||
.where("post_replies.reply_id = ?", post_id)
|
||||
.order(id: :desc)
|
||||
|
||||
referenced_post_message_ids = referenced_posts.map do |referenced_post|
|
||||
|
Loading…
x
Reference in New Issue
Block a user