mercredi 20 avril 2016

SQL Server 2005 - View with linked server vs Query with linked server

  • Server1 - Main reporting server
  • Server2 - Other reporting server

I have a linked server setup between Server1 and Server2.

Server1 has a view that runs a query with multiple joins to gather data from Server2.

When I execute the view on Server1 for year to date data, it takes 5 minutes to run.

When I execute the query on Server1 outside of the view, the query takes 2 minutes.

I've also took the query and built a stored procedure, but that also ran in 5 minutes.

Why is there such a difference between running through a view and running just the query?

Aucun commentaire:

Enregistrer un commentaire