Optimize group by sub query in Mysql
IN
clause the way you used it would be very slow, use JOIN
instead:
SELECT r.* FROM (
SELECT r1.id AS id
FROM faultrefunds_v2 r1
GROUP BY faultid
HAVING count(r1.faultid) > 1
) AS ids
LEFT JOIN faultrefunds_v2 AS r
ON( ids.id = r.id )