Rails - how to add an Index to a database that sorts by 2 where clauses
I have the following:
@count = current_user.participations.joins(:topic).where("topic.status = ? AND pa开发者_如何学JAVArticipations.status = ?","open","unread").count
Right now I have an index for:
- topic.status
- participations.status
1 for each table, Do I need to add an index that combines both to optimize this query?
You would need to add an index on each column. I don't believe you can combine columns from separate tables within a single index.
精彩评论