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

  • Home
  • SEARCH
  • 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 630665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:52:48+00:00 2026-05-13T19:52:48+00:00

Update: After some experimentation, it appears that the thing that is slow is when

  • 0

Update: After some experimentation, it appears that the thing that is slow is when I call “SELECT min(column) FROM theTableValuedFunction()”.

I’ll call the local server ServerLocal and the other remote server ServerForeign. I have a SQL query in a table valued function on ServerLocal that looks like this:

SELECT columns
FROM ServerForeign.database.tableA
JOIN ServerForeign.database.tableB ON columns
JOIN ServerForeign.database.tableC ON columns
JOIN ServerForeign.database.tableD ON columns
JOIN ServerForeign.database.tableE ON columns
JOIN ServerForeign.database.tableF ON columns
WHERE conditions

So here’s my questions:

When I run this, does ServerLocal transmit the whole query to ServerForeign and ask it to do the join itself and get back the results in one operation, or does it grab entire tables, needlessly transmitting everything only to filter it down/join them on ServerLocal?

The “WHERE conditions” in the table valued function are very general; in various places where the table valued function is called it applies further where conditions. Is there any efficiency to be gained by moving those where clauses up into the table valued function code, or is there no difference?

Would there be significant benefit to putting the table valued function on ServerForeign and calling that from ServerLocal, or will I still incur the same slowness just transmitting the data? If I do move the table valued function to ServerForeign, and ServerLocal applies a WHERE clause at the point where it calls the table valued function, is SQL Server smart enough to transmit that WHERE clause from ServerLocal to ServerForeign and use it to reduce the number of rows transmitted, or does it mindlessly return all of them and drop rows that don’t match?

For various external reasons I’d prefer NOT to have to put any code on ServerForeign. If there is a way to run all the SQL code on ServerLocal and still efficiently work with data from ServerForeign, that would be preferable.

  • 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-13T19:52:48+00:00Added an answer on May 13, 2026 at 7:52 pm

    I ran into this myself. A lot of times, the remote tables will be copied over to the local database to execute the query. Try removing any “where” clause criteria on the remote databases and it should speed up.

    Obviously that is not a solution, but most recommend to create a SP or view on the remote database and call that instead.

    So in your case if you create a view, ensure the WHERE clause is on the remote server, at least for the columns that are from the remote tables.

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

Sidebar

Related Questions

Update: After some more reading I see that this problem is totally general, you
Update: I updated this after doing some digging and realizing that this might be
Im trying to update the contents of an element after running some php code.
Because of min time betwwen update it display the location update after 1 sec
I'm trying to write an after update trigger that does a batch update on
UPDATE: After some additional reading, what I really wanted was guaranteed early binding (which
UPDATE: After searching a bit I don't seem to be alone about this problem:
UPDATE: After updating to stylus 0.7.4 and express 2.3.12 I can no longer reproduce
Update: After playing around with this for a few hours, went with a multi-query
Is it possible to update the same view with new data? Using UPDATE after

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.