Gravy


Hi,

I am using Sql 2005 SP1 and merge replication on a database. One of the tables is used for an audit trail and has a dynamic filter applied so that it doesn't replicated every audit trail record to every subscriber.

Our sp's tend to insert records in to the audit trail table when someone inserts a new product (for example). The problem is that just recently the insert of new products has been taking >2 seconds, this is relatively slow compared to how it used to be 2 months ago.

Using profiler I have found that it is the insert in to the audit trail table that is taking all the time, and this is taking a long time because of something replication is doing. From profiler I have found that the following statement is the culprit. This is something that replication is doing but why it take so long I don't know:

select count(*) from [dbo].[MSmerge_repl_view_000CC979122E4C88AF27FE08CDCC84EB_B5F96F71937D4D9A949DEECFE540D0C4] [AUDIT_TRAIL_DETAIL] with (rowlock)
where [RowGUID] in
(select [AUDIT_TRAIL_DETAIL].[RowGUID] from inserted [AUDIT_TRAIL_HEADER],
[dbo].[MSmerge_repl_view_000CC979122E4C88AF27FE08CDCC84EB_B5F96F71937D4D9A949DEECFE540D0C4] [AUDIT_TRAIL_DETAIL] with (rowlock)
where (AUDIT_TRAIL_HEADER.ID = AUDIT_TRAIL_DETAIL.FKAuditTrailHeaderID))

The AUDIT_TRAIL_DETAIL table currently has 1.1 million row in it.

Can anyone give me any clues as to what I should do help improve the performance once again Should I stop filtering on this table

Thanks for your help

Graham




Re: Insert delay

Greg Y


Depending on how deep the filter is (look at the view definitions), it might be by design. You could also look at the query plans to see if it's optimal, or refresh stats. But it's hard to say without some in-depth debugging.




Re: Insert delay

Greg Y

and make sure you have right indexes created on the joined columns.




Re: Insert delay

Gravy

That was it, I was missing an index on one of the foreign keys.

Thanks for your help.