|
Posted by newtophp2000 on 11/17/06 16:20
Hello,
I am trying to find all records that have matching detail_1 or detail_2
columns. This is what I have now:
select t1.id, t1.detail_1, t1.detail_2, t2.id from user_details t1,
user_details t2
where t1.detail_1 = t2.detail_1 or t1.detail_2 = t2.detail_2;
Using smaller tables of around 1000 records, I have verified that this
indeed does the job. However, when I apply it to the real table that
has around 40,000 records, it takes so long that I have to stop the
query.
The table in question is quite simple and is created as follows. There
are no indexes on the table:
create table user_details (id integer, detail_1 varchar(50), detail_2
varchar(50)
Is there a way to make it go faster?
Navigation:
[Reply to this message]
|