One of the major headaches in my replication is the following MS procedure (over 55% usage), updating the distribution history. It currently has one index on columns agent_id, timestamp, runstatus, start_time and time
. When I run a select an add some parameters, the query plan is two items: SELECT (2% cost) and Clustered Index Seek (98%). Now, generally, I'd say that's as good as I can get with this, but was curious if any experts here had some additional techniques they've tried that worked.
UPDATE MSdistribution_history
SET runstatus = @runstatus,
time = @current_time,
duration = @duration,
comments = @comments,
xact_seqno = @xact_seqno,
updateable_row = @this_row_updateable,
error_id =
CASE @error_id
WHEN 0 THEN error_id
ELSE @error_id
END
WHERE agent_id = @agent_id
AND timestamp = @lastrow_timestamp
AND ( runstatus = @runstatus
OR (@update_existing_row = 1
AND runstatus in (@idle, @inprogress)
AND @runstatus in (@idle, @inprogress)) )
Appreciate your help.