0

I am trying to run a query that retrieves data from remote oracle server and then checks if the data retrieved already exists in my database then I will remove it from results.

SELECT DISTINCT 
            col1,
            col2, 
        col3, 
        col4 , 
        col5, 
        col6 , 
        col7, 
        col8 , 
        col9 , 
        col10, 
        col11
        FROM remoteserver.tab1 dist
        JOIN remoteserver.tab2 headers
        ON headers.id1 = dist.id2 
        JOIN remoteserver.tab3 vendors 
        ON headers.id1 = vendors.id3
        JOIN remoteserver.tab4 comb
        ON dist.id2 = comb.id4
          where
    cond1 and cond2 and cond3 and cond4
   SELECT DISTINCT
           col1, 
           col2,
           col3,
           col4,
           col5,
           col6,
           col7,
           col8,
           col9,
          col10,
          col11
   FROM myserver.tab1

This is just an elaboration about the size of the query I am running, the problem is that it takes very long time (around 20 minutes!) to get results. Any suggestions on how to improve performance or achieve same logic using different approach from linked server?

5
  • 1
    HAve you looked at using openrowset? Commented Oct 8, 2013 at 19:02
  • Does what you posted have performance issues? Commented Oct 8, 2013 at 19:12
  • @Blam Yes, This is the query which takes 20 minutes to return results! Commented Oct 8, 2013 at 19:16
  • @HLGEM No, Can you tell me more about it? Commented Oct 8, 2013 at 19:17
  • There are two select statements there. The answer is only as good as the question. Post the problem select and number of rows returned. Commented Oct 8, 2013 at 20:48

1 Answer 1

0

I solved the problem using openrowset, which highly improved performance.

select * from (linkedserver,
'SELECT DISTINCT 
            col1,
            col2, 
        col3, 
        col4 , 
        col5, 
        col6 , 
        col7, 
        col8 , 
        col9 , 
        col10, 
        col11
        FROM remoteserver.tab1 dist
        JOIN remoteserver.tab2 headers
        ON headers.id1 = dist.id2 
        JOIN remoteserver.tab3 vendors 
        ON headers.id1 = vendors.id3
        JOIN remoteserver.tab4 comb
        ON dist.id2 = comb.id4'
          where
    cond1 and cond2 and cond3 and cond4
   SELECT DISTINCT
           col1, 
           col2,
           col3,
           col4,
           col5,
           col6,
           col7,
           col8,
           col9,
          col10,
          col11
   FROM myserver.tab1
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.