MySql - Abysmal Performance
MySql - Abysmal Performance I am trying to run a relatively simple query on a table that has half a million rows. It's just a small fragment I'm using to test the values I get back are correct. The problem is this query takes over 20 minutes to complete, which seems unusually slow even for 500,000 records. DROP VIEW IF EXISTS view_temp_sortie_stats; CREATE VIEW view_temp_sortie_stats AS SELECT server_id, session_id, ucid, role, sortie_id, ( SELECT COUNT(sortie_id) FROM raw_gameevents_log WHERE sortie_id = l.sortie_id AND server_id = l.server_id AND session_id = l.session_id AND target_player_ucid = l.ucid AND event = "HIT" ) AS HitsReceived FROM raw_gameevents_log l WHERE ucid IS NOT NULL AND sortie_id IS NOT NULL GROUP BY server_id, session_id, ucid, role, sortie_id; SELECT * FROM view_temp_sortie_stats; Here is my table: Next I tried to add indexes for server_id, session_id, sortie_id to see if it would improve - this took more than 1...