Last active
November 23, 2016 23:44
-
-
Save zzzprojects/abd9821e2c2d684bf7582fd941acc7f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set Global Configuration | |
BulkOperationManager.BulkOperationBuilder = operation => operation.BatchSize = 1000; | |
// Set Instance Configuration | |
context.BulkSaveChanges(operation => operation.BatchSize = 100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context.BulkSaveChanges(operation => | |
{ | |
// Increasing/Decreasing the value affects the performance | |
// There is no perfect value, it depends on column, trigger, index, etc. | |
operation.BatchSize = 100; // Default value = 10,000 for SQL Server | |
// Specify the timeout for a batch | |
operation.BatchTimeout = 180; // seconds, default value = 15s | |
// Specify the delay between batch executions | |
operation.BatchDelayInterval = 100; // milliseconds, default value = 0 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context.BulkSaveChanges(operation => | |
{ | |
// Specify how many batch a temporary table must contain | |
bulk.TemporaryTableBatchByTable = 5; // Default value = 0 (infinite) | |
// Can increase/decrease performance depending on the number of columns | |
bulk.TemporaryTableInsertBatchSize = 1000; // Default value = 10,000 | |
// Increasing the value may improve performance for sources with few records | |
bulk.TemporaryTableMinRecord = 15; // Default value = 10 | |
// Using TableLock may increase performance but also increase row lock | |
bulk.TemporaryTableUseTableLock = true; // Default value = false | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context.BulkSaveChanges(operation => | |
{ | |
// SET default options to use when a SqlBulkCopy instance is used | |
bulk.SqlBulkCopyOptions = SqlBulkCopyOptions.Default | SqlBulkCopyOptions.TableLock; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment