mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 17:06:31 -06:00
PERF: Add index to speed up ReindexSearch job (#20151)
This commit is contained in:
parent
692e843832
commit
b96a23978a
@ -1285,16 +1285,17 @@ end
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# idx_posts_created_at_topic_id (created_at,topic_id) WHERE (deleted_at IS NULL)
|
||||
# idx_posts_deleted_posts (topic_id,post_number) WHERE (deleted_at IS NOT NULL)
|
||||
# idx_posts_user_id_deleted_at (user_id) WHERE (deleted_at IS NULL)
|
||||
# index_for_rebake_old (id) WHERE (((baked_version IS NULL) OR (baked_version < 2)) AND (deleted_at IS NULL))
|
||||
# index_posts_on_id_and_baked_version (id DESC,baked_version) WHERE (deleted_at IS NULL)
|
||||
# index_posts_on_image_upload_id (image_upload_id)
|
||||
# index_posts_on_reply_to_post_number (reply_to_post_number)
|
||||
# index_posts_on_topic_id_and_percent_rank (topic_id,percent_rank)
|
||||
# index_posts_on_topic_id_and_post_number (topic_id,post_number) UNIQUE
|
||||
# index_posts_on_topic_id_and_sort_order (topic_id,sort_order)
|
||||
# index_posts_on_user_id_and_created_at (user_id,created_at)
|
||||
# index_posts_user_and_likes (user_id,like_count DESC,created_at DESC) WHERE (post_number > 1)
|
||||
# idx_posts_created_at_topic_id (created_at,topic_id) WHERE (deleted_at IS NULL)
|
||||
# idx_posts_deleted_posts (topic_id,post_number) WHERE (deleted_at IS NOT NULL)
|
||||
# idx_posts_user_id_deleted_at (user_id) WHERE (deleted_at IS NULL)
|
||||
# index_for_rebake_old (id) WHERE (((baked_version IS NULL) OR (baked_version < 2)) AND (deleted_at IS NULL))
|
||||
# index_posts_on_id_and_baked_version (id DESC,baked_version) WHERE (deleted_at IS NULL)
|
||||
# index_posts_on_id_topic_id_where_not_deleted_or_empty (id,topic_id) WHERE ((deleted_at IS NULL) AND (raw <> ''::text))
|
||||
# index_posts_on_image_upload_id (image_upload_id)
|
||||
# index_posts_on_reply_to_post_number (reply_to_post_number)
|
||||
# index_posts_on_topic_id_and_percent_rank (topic_id,percent_rank)
|
||||
# index_posts_on_topic_id_and_post_number (topic_id,post_number) UNIQUE
|
||||
# index_posts_on_topic_id_and_sort_order (topic_id,sort_order)
|
||||
# index_posts_on_user_id_and_created_at (user_id,created_at)
|
||||
# index_posts_user_and_likes (user_id,like_count DESC,created_at DESC) WHERE (post_number > 1)
|
||||
#
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user