2
3つの表に対して結合を実行しているため、何らかの理由で表の1つで索引を使用できません。私はフィールド(date, team)
と(date, team, player_id)
とどちらも適用されているため、DFSにインデックスを持っているSQL結合の索引
SELECT * FROM nfl_schedules ns
join nfl_daily_fantasy_players dfs
on dfs.date = ns.date and dfs.team = ns.home_team
left join fantasy_salaries sal
on sal.platform_id = (SELECT id FROM platforms p WHERE p.platform = 'draft_kings') and sal.game_key = ns.game_key and sal.player_id = dfs.player_id
left join nfl_players np
on np.player_id = dfs.player_id
where ns.timeframe = @frame;
:ここ
はクエリです。これは、索引が適用されていない唯一の表です。余分にそれはどこを使用していると言います。アイデア?
id,select_type,table,type,possible_keys,key,key_len,ref,rows,Extra
1,PRIMARY,dfs,ALL,"date_team,date_team_player_id",NULL,NULL,NULL,4920,"Using where"
1,PRIMARY,ns,ref,"date_team_timeframe,date_team",date_team_timeframe,264,"draftcrunch_new.dfs.date,draftcrunch_new.dfs.team",1,"Using index condition"
1,PRIMARY,sal,ref,"unique,index3,index4,index5",index4,262,"draftcrunch_new.dfs.player_id,draftcrunch_new.ns.game_key",1,"Using where"
1,PRIMARY,np,ref,"unique_players,index3",unique_players,4,draftcrunch_new.dfs.player_id,1,NULL
2,SUBQUERY,p,const,platform,platform,257,const,1,"Using index"
投稿プランの説明 –
書式を設定する最善の方法は不明です。しかしそこにはあります。 1行目では、dfsのインデックスを使用していません。 –
create indexステートメントをdfsに表示できますか? – ESG