Home All Groups Group Topic Archive Search About

Most efficient way to query a remote server

Author
22 Jul 2005 11:58 AM
Enric
Dear all,

Using OPENQUERY or through of server.db.owner.table?

Regards,

Author
22 Jul 2005 12:14 PM
ML
The second option provides less typing on your part. So, in a way, it's the
more efficient one.


ML
Author
23 Jul 2005 11:01 AM
Razvan Socol
Usually, I prefer the four-part names. However, If the query is more
complex, involving several remote tables and no local tables, I'd say
that OPENQUERY may be better in certain situations, because Books
Online says (in the "Distributed Query Architecture" topic, regarding
linked servers):

   When possible, SQL Server pushes relational operations such as
   joins, restrictions, projections, sorts, and group by operations
   to the OLE DB data source. SQL Server does not default to scanning
   the base table into SQL Server and performing the relational
   operations itself. SQL Server queries the OLE DB provider to
   determine the level of SQL grammar it supports, and, based on that
   information, pushes as many relational operations as possible to
   the provider.

>From this paragraph, I understand that there are some queries that may
not be supported by the OLE DB provider, so those queries may run
locally with the four-part naming syntax, but are forced to run
remotely with the OPENQUERY syntax. However, I do not have an example
of such query, so you can stick to the four-part naming syntax (until
you find an evidence that a particular query is run locally, even if
it's possible to run remotely).

Razvan

AddThis Social Bookmark Button