troubleshooting Question

sql openquery run time is really long

Avatar of Jacob L
Jacob LFlag for United States of America asked on
SQLDatabasesOracle DatabaseMicrosoft SQL Server
4 Comments2 Solutions24 ViewsLast Modified:
Hi experts,
i have this query that uses a linked server (from_ams) to connect to an oracle database. The query takes 12 minutes to run and I am just comparing about 10 records. I believe what is happening is the openquery is pulling every record from the oracle side which is millions of records. Is there any modifications I can make to this query to compare only the records in the WM_EME_to_AMS_PointsCompareFULL table?

sql query:
select a.HH_NUM, p.Amount, eme.HH_NUM, eme.emeBalance  
      from WM_EME_to_AMS_PointsCompareFULL a
         join CardIDs b on CONVERT(bigint, b.ExtCardID) = a.HH_NUM and b.CardTypeID = 1
         inner join points p on b.CustomerPK = p.CustomerPK and ProgramID = 1
             inner join Openquery([from_ams], ' SELECT H.HH_NUM, H.SPTSACCU10 as emeBalance FROM  EME.HOUSEHOLD H ' ) eme on a.HH_NUM = eme.hh_num
Andrei Fomitchev

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros