Query takes time on comparing non numeric data of two tables, how to optimize it?
Posted
by Muhammad Kashif Nadeem
on Stack Overflow
See other posts from Stack Overflow
or by Muhammad Kashif Nadeem
Published on 2010-04-21T14:15:51Z
Indexed on
2010/04/21
17:03 UTC
Read the original article
Hit count: 237
I have two DBs. The 1st db has CallsRecords table and 2nd db has Contacts table, both are on SQL Server 2005.
Below is the sample of two tables.
Contact table has 1,50,000 records
CallsRecords has 75,000 records
Indexes on CallsRecords:
CallFrom
CallTo
PickUP
Indexes on Contacts:
PhoneNumber
I am using this query to find matches but it take more than 7 minutes.
SELECT *
FROM CallsRecords r INNER JOIN Contact c ON r.CallFrom = c.PhoneNumber
OR r.CallTo = c.PhoneNumber OR r.PickUp = c.PhoneNumber
In Estimated execution plan inner join cost 95%
Any help to optimize it.
© Stack Overflow or respective owner