Your group by isn't going to give you unique values and Joining in the having clause is what's slowing you down
SELECT
t1.f1,
t1.f2,
t2.f1
FROM
table1 AS t1
LEFT JOIN table2 AS t2 ON t1.f1 = t2.f2
If you only want records where they existi in both tables replace the LEFT JOIN with an INNER JOIN
Also, if you only want distinct rcords of t1.f1, t1.f2, t2.f1 then either do
SELECT DISTINCT rather than SELECT
or GROUP BY t1.f1, t1.f2, t2.f1