Quantcast
Channel: SQL Server Replication forum
Viewing all articles
Browse latest Browse all 4054

Slow Merge Replication

$
0
0

We are using merge replication with SQL 2012. The first sync we do is slow, and often times out. We are using precomputed partitions.

We have traced it back to this SQL statement being called in sp_MSsetupbelongs

select distinct b.tablenick, b.rowguid, c.colv1, c.generation, c.lineage, 
sys.fn_MSgeneration_downloadonly(c.generation, c.tablenick), 
sys.fn_MSvector_downloadonly(c.lineage, c.tablenick), 
sys.fn_MSvector_downloadonly(c.colv1, c.tablenick) from
                #belong b left outer join dbo.MSmerge_contents c
                on  c.tablenick = b.tablenick and c.rowguid = b.rowguid

Which is very slow.

The #belong table is a temporary table being created like this,

create table #belong (tablenick int NOT NULL, rowguid uniqueidentifier NOT NULL, flag int NOT NULL, partchangegen bigint null, skipexpand bit NOT NULL)

When I look at the sp_MSsetupbelongs stored procedure I can see that there is a parameter on it called @enumentirerowmetadata and it is being set to 0. This is our problem potentially, but I need to know what that parameter is.

When it is being set to 1 the above SQL becomes this (just guessing by tracing through the stored procedure),

select distinct b.tablenick, b.rowguid, c.generation, c.lineage, c.colv1
from
                #belong b left outer join dbo.MSmerge_contents c
                on  c.tablenick = b.tablenick and c.rowguid = b.rowguid

And it runs instantly. The first SQL statement doesn't seem right because the functions will be run on every row that is queried, but there must be a purpose.



Viewing all articles
Browse latest Browse all 4054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>