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:
Sam
2019-01-06 15:14:41 +11:00
parent effb3262a1
commit 37088c4221

View File

@@ -0,0 +1,5 @@
class AddTopicIdIndexToUserHistories < ActiveRecord::Migration[5.2]
def change
add_index :user_histories, [:topic_id, :target_user_id, :action]
end
end