mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: index on topic_id for user_histories table
We query this table when getting composer messages with the queries such as: ``` SELECT 1 AS one FROM "user_histories" WHERE "user_histories"."target_user_id" = 1 AND "user_histories"."action" = 9 AND "user_histories"."topic_id" = 105794 LIMIT 1 ``` This index ensures this query remains very quick, regardless of user history size.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
class AddTopicIdIndexToUserHistories < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_index :user_histories, [:topic_id, :target_user_id, :action]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user