mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: Add index id DESC, baked_version ON posts.
A scheduled job runs `Post.rebake_old` with a limit of 80 which does a look up for the latest posts that have not been baked to the latest version. Before this commit, the query would run using the primary key's index and does a reverse scan. However the query performance quicky becomes bad as more and more of the latest posts have been baked to the latest version.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
class AddIndexIdBakedVersionOnPosts < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_index :posts, [:id, :baked_version],
|
||||
order: { id: :desc },
|
||||
where: "(deleted_at IS NULL)"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user