locked
Guideline on value for BatchSize in bytes? RRS feed

  • Question

  • Any guidelines on what factors go into choosing a BatchSize value?

    I know that the value does have to be non-zero in order to turn batching on ... and that if it is smaller than the single largest record it will throw an excption.  I don't know if it is the sync or any particular table ... but if the size one of these is less than the BatchSize value ... batching is not used.

    Other than this ... is it better to have the value as large as possible to reduce the number of files created ... or as small as possible to ensure batching is used (assuming I correctly understand the above)?  It appears on my largest table that about 15 batch files are created when I have the value set at 1000.  I am trying to decide if it would be better to set the BatchSize value around 5000 ... but I don't know what factors should go into this decision.

    Any best practices or insight would be appreciated!

    Tuesday, July 5, 2011 4:10 PM

Answers

  • assuming you're referring to MemoryDataCacheSize (for SqlSyncProvider/SqlCeSyncProvider), the main factors for choosing batch size is available memory and the reliability of the connection. by default, Sync Fx serializes the changes as a Dataset. The dataset is cached in memory.  If you enable batching, the changes are spooled to files.

    batching also helps in unreliable networks by reducing the need to re-enumerate and re-download changes when a sync operation fails. it can use the spooled files to determine where to resume.

    please note though even if you enable batching, all the batches are treated still as a single transaction. batching is just for the transmission of the changes.

    you'll have to test which batch size works best for your scenario. If you have enough memory and reliable network, then bigger batches works best since you reduced the need to spool to files and reduce I/O operations (spooling batch files and SQL operations)

    • Marked as answer by P H T Monday, July 18, 2011 2:19 PM
    Wednesday, July 6, 2011 1:04 AM