DEV: Drop search index on non-pm posts.

The problem with this index is that on sites with a high non-pm to pm
posts ratio, the index is esstentially duplicating the existing index on
`PostSearchData#search_data`. If the site is huge, the index ends up
taking up more diskspace.
This commit is contained in:
Guo Xiang Tan 2020-08-21 07:21:34 +08:00
parent c8faad62ad
commit 87de8948c0
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
2 changed files with 11 additions and 12 deletions

View File

@ -0,0 +1,11 @@
class DropIdxRegularPostSearchData < ActiveRecord::Migration[6.0]
def up
execute <<~SQL
DROP INDEX CONCURRENTLY IF EXISTS idx_regular_post_search_data
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end

View File

@ -34,13 +34,6 @@ class UpdatePrivateMessageOnPostSearchData < ActiveRecord::Migration[6.0]
end
def up
# must drop index cause we do not want an enormous amount of work done
# as we are changing data
execute <<~SQL
DROP INDEX CONCURRENTLY IF EXISTS idx_regular_post_search_data
SQL
# Delete post_search_data of orphaned posts
execute <<~SQL
DELETE FROM post_search_data
@ -69,11 +62,6 @@ class UpdatePrivateMessageOnPostSearchData < ActiveRecord::Migration[6.0]
update_private_message_flag
change_column_null(:post_search_data, :private_message, false)
end
execute <<~SQL
CREATE INDEX CONCURRENTLY idx_regular_post_search_data
ON post_search_data USING GIN(search_data) WHERE NOT private_message
SQL
end
def down