开发者

Rails - how to add an Index to a database that sorts by 2 where clauses

开发者 https://www.devze.com 2023-01-30 09:55 出处:网络
I have the following: @count = current_user.participations.joins(:topic).where(\"topic.status = ? AND pa开发者_如何学JAVArticipations.status = ?\",\"open\",\"unread\").count

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

精彩评论

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