kandarp
kandarp

Reputation: 343

Sync Framework 2.1 taking too much time to sync for first time

I am using sync framework 2.1 to sync my database and it is unidirectional only i.e. source to destination database. I am facing problem while syncing database for the first time. I have divided tables in different groups so that there is less overhead while syncing. I have one table which has 900k records in it. While syncing that table, SyncOrchestrator.Synchronize(); method not returning anything. Network usage,disk i/o everything goes high. I have wait to complete the sync process for 2 days but it still happening nothing. I have also check in sql db using "sp_who2" and the process is in suspended mode. I have also use some queries found from online and it says table_selectchanges takes too much time.

I have used following code to sync my database.

//setup the connections
var serverConn = new SqlConnection(sourceConnectionString);
var clientConn = new SqlConnection(destinationConnectionString);

// create the sync orchestrator
var syncOrchestrator = new SyncOrchestrator();

//setup providers
var localProvider = new SqlSyncProvider(scopeName, clientConn);
var remoteProvider = new SqlSyncProvider(scopeName, serverConn);

localProvider.CommandTimeout = 0;
remoteProvider.CommandTimeout = 0;

localProvider.ObjectSchema = schemaName;
remoteProvider.ObjectSchema = schemaName;

syncOrchestrator.LocalProvider = localProvider;
syncOrchestrator.RemoteProvider = remoteProvider;

// set the direction of sync session Download
syncOrchestrator.Direction = SyncDirectionOrder.Download;

// execute the synchronization process
syncOrchestrator.Synchronize();

Upvotes: 1

Views: 520

Answers (1)

user11804840
user11804840

Reputation: 11

We had this problem. We removed all the foreign key constraints from the database for the first sync. This reduced the initial sync from over 4 hours to about 10 minutes. After the initial sync completed we replaced the foreign key constraints.

Upvotes: 1

Related Questions