Very slow SQL update using linked server

I have a sql script running on a server (ServerA) A linked server (ServerB) is installed on this server - it is located outside the site in the data center.

This query works relatively simple:

SELECT OrderID
FROM [ServerB].[DBName].[dbo].[MyTable]
WHERE Transferred = 0

However, when updating the same table using this query:

UPDATE [ServerB].[DBName].[dbo].[MyTable]
SET Transferred = 1

It takes> 1 minute to complete (even if there is only 1 column where Transferred = 0)

Is there a reason this will act so slowly? Should I have an index in MyTable for the Migrate column?

+3
source share
3 answers

( SQL-) , ( ) , . (, 10 / ), .

- ( ). , - .

+8
UPDATE [ServerB].[DBName].[dbo].[MyTable]
SET Transferred = 1
WHERE Transferred = 0   -- missing this condition?
+3

?

, /.

Each process updates the table without filtering records, the entire table is blocked by a transaction and another procession, which should update the expectations in the table.

In this case, you can expect some other process to open the table.

0
source

Source: https://habr.com/ru/post/1785889/


All Articles