Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 755787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:10:12+00:00 2026-05-14T15:10:12+00:00

I have two DBs. The 1st db has CallsRecords table and 2nd db has

  • 0

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

alt text http://img688.imageshack.us/img688/8422/calls.png

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:10:13+00:00Added an answer on May 14, 2026 at 3:10 pm

    You could try getting rid of the or in the join condition and replace with union all statements. Also NEVER, and I do mean NEVER, use select * in production code especially when you have a join.

    SELECT <Specify Fields here>
    FROM CallsRecords r INNER JOIN Contact c ON r.CallFrom = c.PhoneNumber  
    UNION ALL
    SELECT <Specify Fields here>    
    FROM CallsRecords r INNER JOIN Contact c ON r.CallTo = c.PhoneNumber 
    UNION ALL
    SELECT <Specify Fields here> 
    FROM CallsRecords r INNER JOIN Contact c ON r.PickUp = c.PhoneNumber 
    

    Alternatively you could try not using phone number to join on. Instead create the contacts phone list with an identity field and store that in the call records instead of the phone number. An int field will likely be a faster join.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hoping someone has experience with both sql server and postgresql. Between the two db's,
In my project I have two separate DBs on the same server. The DBs
I have two identical tables and need to copy rows from table to another.
Have two fields start and end, both are dates, I want to write a
SQL Server express editions have memory limit of 1GB. Can I install multiple versions
We have a new installation of TFS 2010 (on SQL Server 2008), and I'm
Have two variables both containing integers: var input; var value; Need to perform arithmetic
ok, say you have two dbs. one you use as a master template which
I have MS SQL Server 2008 installed on my machine and also ‘Reporting Services
I have a situation that requires two SQL Compact edition databases to synchronise with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.