开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜