I am currently using the following query to select a players most recent winning streak and the query works great other then the fact it takes way too long to load when dealing with a lot of records.
select sum(id > coalesce((select max(id) from cc6_MensLeague_rounds p2 where p2.player = 1184 and p2.outcome = 1),0)) as current from cc6_MensLeague_rounds p where player = 1184 and outcome = 2;
My question is... Is there a more efficient way to return the same results in less time?
The expected output for this query is
Current
6
I have set up a MySql fiddle at: https://www.db-fiddle.com/f/nMKRZe4EAHwqh1wfmsUbrQ/0