Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linked Server delete and insert speed issue

Status
Not open for further replies.

hoggle

Programmer
Jul 13, 2001
124
US
We have a linked server and everything works fine, except whenever I need to run a delete or insert command the process is terribly slow. We have a T1 connection between the two sites and it only deletes around 100 records, which seems like it shouldn't take 15 minutes to run, but it does.

I issue the DELETE command like this:
(LOFTHOUSESQL2 being the linked server)
DELETE LOFTHOUSESQL2.QueryTrx.dbo.SO_90_UDF_Sales_Order
FROM LOFTHOUSESQL2.QueryTrx.dbo.SO_90_UDF_Sales_Order t1, #temp t2
WHERE t1.SalesOrderNumber = t2.SalesOrderNumber

I've read that this can also be done using the OPENQUERY command, which helps the speed, but I cannot find any documentation on using the DELETE or INSERT command while using OPENQUERY.

So basically I guess what I'm asking is, does the OPENQUERY command improve the speed (if so anyone have some sample delete and insert syntax) or is there another way to improve the speed?

thanks for any insight.
 
I didn't realize I didn't say that both servers are SQL Server 2000.
 
hoggle,

You are encountering serveral problems with cross server joins. Your temp table resides on the calling server.

Create the temp table on the destination server instead. That way the joined tables will all be on the same server and the query optimizer can create more efficient query plans.

Also, it is good practice to put your SQL commands in stored procedures if you haven't already done so.

One more thing, check the properties of your linked servers. Make sure the Collation Compatible checkbox is checked (by default it is unchecked), that is of course assuming the collation is the same on the two SQL Servers. Otherwise, one of the servers has to perform a collation conversion everytime data is compared between the two servers.

bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top