mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 21:50:48 +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:
@ -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}>"
|
"<topic/#{topic_id}/#{post_id}@#{host}>"
|
||||||
|
|
||||||
referenced_posts = Post.includes(:incoming_email)
|
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)
|
.order(id: :desc)
|
||||||
|
|
||||||
referenced_post_message_ids = referenced_posts.map do |referenced_post|
|
referenced_post_message_ids = referenced_posts.map do |referenced_post|
|
||||||
|
Reference in New Issue
Block a user