Public feed #598968

Something

public text v1 · immutable
Raw Edit
·published 2007-07-01 18:48 UTC
rendered paste body
My query, when do the ORDER BY at the end, is 12 seconds long. It's 45ms if I don't do the ORDER by. I tried indexing every fricken column in both tables, and that didn't help. any ideas?

I have two tables, here is my query below. Basically TDM_Matches contains a player_1_id and a player_2_id , and then TDM_Players contains information about those players, referenced by player_1_d and player_2_id in the TDM_Matches table. 

The issue is using temporary, using filesort;... I just don't know how to get rid of it. If I don't do the ORDER BY, everything is fine. Any ideas? Every single column that is listed in the query is indexed... maybe I did that wrong?


EXPLAIN SELECT 
p1.first_name p1_first_name, p1.last_name p1_last_name, 
p2.first_name p2_first_name, p2.last_name p2_last_name, 
winner_id, score, match_id FROM tennisdraws.TDM_Match m JOIN tennisdraws.TDM_Player as p1 ON m.player_1_id = p1.player_id 
JOIN tennisdraws.TDM_Player as p2 ON m.player_2_id = p2.player_id 
WHERE m.event_id='1' AND match_id<'1000'
ORDER BY m.match_id ASC

"1","SIMPLE"," p1","ALL",\N,\N,\N,\N," 165","Using temporary; Using filesort"
"1","SIMPLE"," p2","ALL",\N,\N,\N,\N," 165",""
"1","SIMPLE"," m","index","match_id ","match_id","931" ,\N,"340","Using where; Using index"