From d1f721b249d86400226c2f91a89390407e01cc62 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 28 Jun 2019 14:12:04 +0800 Subject: [PATCH] left out join --- app/controllers/challenges_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 3782468d4..5503dfe63 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -150,7 +150,7 @@ class ChallengesController < ApplicationController uid_logger("identifier: #{params}") # 通过调试发现 这里includes(:games)性能会慢10倍 # @challenges = @shixun.challenges.fields_for_list - @challenges = Challenge.fields_for_list.includes(:games).where("challenges.shixun_id" => @shixun.id) + @challenges = Challenge.fields_for_list.left_outer_joins(:games).where("challenges.shixun_id" => @shixun.id) # @challenges = Challenge.includes(:games).where("games.user_id" => 12).where(shixun_id: @shixun.id)