% rails g model comment post:references body:text - indexed ★ % rails g migration add_user_id_to_comment user_id:integer - not indexed Monday, September 3, 12
class Activity < ActiveRecord::Base ... # ड͚औͬͨactivitiesΛɺpublication_idͷ͝ͱʹ࠷େ7݅ͣͭʹߜͬͯฦ͢ # [MySQLݶఆ] def self.select_top_7_per_publication_id(activities) # ࠷৽ͷ6+1݅(see moreΛදࣔ͢Δ͔Ͳ͏͔Λఆ͢ΔͨΊʹ͑ͯ1݅ଟΊʹऔಘ) Activity.from(<<-SQL).where("activities.row_number <= #{DISPLAY_ACTIVITY_NUM + 1}") (select *, if(@previous_publication_id <> publication_id, @rownum := 1, @rownum := @rownum + 1) as row_number, @previous_publication_id := publication_id from (#{activities.to_sql}) as a cross join (select @rownum := NULL, @previous_publication_id := 0) as r order by publication_id, id desc ) AS activities SQL end ... end ΩϞ͍ Monday, September 3, 12
resources prevents blocking of other downloads, and it also enables progressive rendering.” https://developers.google.com/speed/ docs/best-practices/ rtt#PutStylesBeforeScripts Monday, September 3, 12