if you want to identify duplicates and read them at the same time, you can use:
SELECT if(id1 < id2, id1, id2), if (id1 < id2, id2, id1), count(*) FROM your_table GROUP BY 1,2 HAVING count(*) > 1
This does not complete the connection, which may be faster at the end.
source share