none
Defrag during sync session RRS feed

  • Question

  • Hi,

    We are using the Sync Framework 2.1 in a production environment.  It works reasonably well.  Sometimes there are very large syncs (>> 1 GB) which not only take a long time, but slow down as the indexes become more and more fragmented.  This is despite running maintenance jobs which defrag several times daily.  In extreme cases, the sync bogs down so badly we have to kill the process, do a defrag, and restart.

    Thinking it might be helpful to defrag after each transaction is committed, I wrote some code to defrag the indexes of selected tables and called it in the RemoteProvider_ChangesApplied event.  Unfortunately, the defrag process would not run because it was blocked by locks held by the sync session itself.  

    So I tried calling e.Transaction.Commit() before calling defrag. The defrag then worked, but then ApplyChanges failed, apparently because it did not like having the transaction committed before its time.

    Finally I called defrag at the conclusion of ApplyChanges.  This works, except not only does it get called way too often before any changes to the database occur, but more importantly, it only gets called once after all the changes, not after every transaction like I would like.

    So the question is:  is there any way to be able to defrag the indexes midway through the process?

    Thanks.

    Dan


    Dan Hurwitz

    Friday, January 6, 2017 10:32 PM