0
이이 덜 SQL 쿼리를 만들 수있는 기술이 거기에 내가 전체 카운트 수를 얼마나, 그리고 @codes
객체SQL을 줄이면서 어떻게 속도를 높일 수 있습니까?
@codes = user.codes.joins(:community).merge(Community.not_deleted).order("codes.updated_at DESC").limit(10)
@codes_count = user.codes.joins(:community).merge(Community.not_deleted).order("codes.updated_at DESC").count
?
는
@codes_all = user.codes.joins(:community).merge(Community.not_deleted).order("codes.updated_at DESC")
@codes_count = @codes_all.count
@codes = @codes_all.limit(10)
그것이 가능 같은 이런이 열망 로딩 뭔가를 만드는 방법?
@codes_all = user.codes.includes(community: [:country, :language]).joins(:community).merge(Community.not_deleted).order("codes.updated_at DESC")
@codes_count = @codes_all.count
@codes = @codes_all.limit(10)