mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 02:58:48 +08:00
PERF: Drop user_search_similar_results
site setting (#28874)
In 14cf8eacf1a679c08ea7df93aff17949d1a9c4df, we added the `user_search_similar_results` site setting which when enabled will use trigram matching for similarity search in `UserSearch`. However, we noted that adding the `index_users_on_username_lower_trgm` index is causing the PG planner to not use the `index_users_on_username_lower` index when the `=` operator is used against the `username_lower` column. Based on the PG mailing list discussion where support for the `=` operator in gist_trgm_ops was being considered, it stated that "I also have checked that btree_gist is preferred over pg_trgm gist index for equality search." This is however quite different from reality on our own PG clusters where the btree index is not preferred leading to significantly slower queries when the `=` operator is used. Since the pg_trgm gist index is only used for queries when the `user_search_similar_results` site setting is enabled, we decided to drop the feature instead as it is hidden and disabled by default. As such, we can consider it experiemental and drop it without deprecation. PG mailing list discussiong: https://www.postgresql.org/message-id/CAPpHfducQ0U8noyb2L3VChsyBMsc5V2Ej2whmEuxmAgHa2jVXg%40mail.gmail.com
This commit is contained in:

committed by
GitHub

parent
c182bb34ad
commit
97143efc52
@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
class DropUserSearchSimilarResultsSiteSetting < ActiveRecord::Migration[7.1]
|
||||
def up
|
||||
execute <<~SQL
|
||||
DELETE FROM site_settings WHERE name = 'user_search_similar_results';
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
13
db/migrate/20240912061806_drop_trgm_indexes_on_users.rb
Normal file
13
db/migrate/20240912061806_drop_trgm_indexes_on_users.rb
Normal file
@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
class DropTrgmIndexesOnUsers < ActiveRecord::Migration[7.1]
|
||||
def up
|
||||
execute <<~SQL
|
||||
DROP INDEX IF EXISTS index_users_on_username_lower_trgm;
|
||||
DROP INDEX IF EXISTS index_users_on_name_trgm;
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user