Примерно так:
select * from (
select
n.id as needle_id,
h.id as haystack_id,
case when n.a = h.a then 1 else 0 end
+ case when n.b = h.b then 1 else 0 end
+ case when n.c = h.c then 1 else 0 end
+ case when n.d = h.d then 1 else 0 end
+ case when n.e = h.e then 1 else 0 end
+ case when n.f = h.f then 1 else 0 end as matching_columns_count
from
my_table n
join
my_table h
on
n.a = h.a
or n.b = h.b
or n.c = h.c
or n.d = h.d
or n.e = h.e
or n.f = h.f
order by
matching_columns_count desc
) z where matching_columns_count >= 3
Где {a,b,c,d,e,f}
- названия столбцов в вашей таблице
Я сомневаюсь, что это будет быстро