You are here: Optimize query « MsSQL Server « IT news, forums, messages
Optimize query

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация