I am using simple update statement for specific primary key for SQL linked server as follow
UPDATE t
SET
processed = 1,
processed_on = GETDATE()
FROM [LINKED\SERVER].DATABASE.dbo.FileQueue t
WHERE t.FileId = '3b33eff6-fde1-4e8c-9c23-2dbd45f50222'
The both servers are SQL Server 2019. The table definition is
CREATE TABLE dbo.FileQueue
(
FileId UNIQUEIDENTIFIER NOT NULL,
Processed BIT NOT NULL,
Processed_on DATETIME NULL
CONSTRAINT PK_FileQueue PRIMARY KEY CLUSTERED
(
FileId ASC
)
)
The Processed column has bit type. The query is slow due to full table scan.
Why is this happening? When I remove the bit column from the statement, everything works fine as usual with reading and updating single remote row.
The Id
column is the clustered primary key. I have a ton of tables with a similar key.
I tried with CONVERT
or CAST
function and the result is the same.
For query without bit column the execution plan is pretty well.
UPDATE t
SET
--processed = 1,
-- any other columns can be added to be updated except bit
processed_on = GETDATE()
FROM [LINKED\SERVER].DATABASE.dbo.FileQueue t
WHERE t.FileId = 'ABD4442F-8560-43B5-8B04-000000B2A626'