I seem to be a little stuck. This is a fairly direct request.
If I run the queries separately, it is not so slow, but when I combine them, it is very slow.
I'm not sure how to optimize it. Any help is appreciated. Basically I want to show some returns. So where the faultid exists more than once.
SELECT r.* FROM faultrefunds_v2 r WHERE r.id IN (SELECT r1.id FROM faultrefunds_v2 r1 GROUP BY faultid HAVING count(r1.faultid) > 1);
The explanation results are attached as an image.

performance mysql group-by subquery
Robbo_UK
source share