rails - created_at when user for ordering, Should you add an Index to the table?

前端 未结 3 1226
萌比男神i
萌比男神i 2021-02-01 21:24

Hello for one of my models photos I have:

default_scope :order => \'photos.created_at DESC, photos.version DESC\'

Given that I\'m ordering b

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-01 21:59

    Was just reading up on this last night as I was adding indices to a number of tables. The short answer is 'yes'. The case is quite eloquently made here:

    https://web.archive.org/web/20140426154227/https://tomafro.net/2009/08/using-indexes-in-rails-choosing-additional-indexes

    The longer answer is also 'yes' but why don't you test it out a bit and see what sort of mileage you get out of it based on how your app interacts with the data.

提交回复
热议问题