mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: Add index to speed up ReindexSearch job (#20151)
This commit is contained in:
committed by
GitHub
parent
692e843832
commit
b96a23978a
@@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddIndexToPostsWhereNotDeletedOrEmpty < ActiveRecord::Migration[7.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
execute <<~SQL
|
||||
DROP INDEX CONCURRENTLY IF EXISTS index_posts_on_id_topic_id_where_not_deleted_or_empty
|
||||
SQL
|
||||
|
||||
execute <<~SQL
|
||||
CREATE INDEX CONCURRENTLY index_posts_on_id_topic_id_where_not_deleted_or_empty ON posts (id, topic_id) where deleted_at IS NULL AND raw <> ''
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
execute <<~SQL
|
||||
DROP INDEX IF EXISTS index_posts_on_id_topic_id_where_not_deleted_or_empty
|
||||
SQL
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user