- Main Features
-
Bulk Options
- Bulk Options
- Audit
- Batch
-
Column
- Column Input Expression
- Column Output Expression
- Column InputOutput Expression
- Column PrimaryKey Expression
- Column Synchronize DeleteKey Subset Expression
- Ignore OnInsert Expression
- Ignore OnMergeInsert Expression
- Ignore OnMergeMatched AndCondition Expression
- Ignore OnMergeMatched AndOneNotCondition Expression
- Ignore OnMergeUpdate Expression
- Ignore OnSynchronizeInsert Expression
- Ignore OnSynchronizeMatched AndCondition Expression
- Ignore OnSynchronizeMatched AndOneNotCondition Expression
- Ignore OnSynchronizeUpdate Expression
- Ignore OnUpdate Expression
- Ignore OnUpdateMatched AndCondition Expression
- Ignore OnUpdateMatched AndOneNotCondition Expression
- MergeMatched AndCondition Expression
- MergeMatched AndNotCondition Expression
- SynchronizeMatched AndCondition Expression
- SynchronizeMatched AndOneNotCondition Expression
- UpdateMatched AndCondition Expression
- UpdateMatched AndOneNotCondition Expression
- Coalesce Destination OnMergeUpdate Expression
- Coalesce Destination OnUpdate Expression
- Coalesce OnMergeUpdate Expression
- Coalesce OnUpdate Expression
- Context Factory
- Execute Event
- ExplicitValueResolutionMode
- Identity
- Include Graph
- ForceValueGeneratedStrategy
- Key
- Logging
- Rows Affected
- Temporary Table
- Transaction
- Transient Error
- SQL Server
- Coalesce
- Coalesce Destination
- Delete Matched and Condition
- Delete Matched and one NOT Condition
- Delete Matched and Formula
- Matched and Condition
- Matched and one NOT Condition
- Matched and Formula
- Batch Operations
- Events
- Utilities
- C# Eval Expression
- Articles
- Troubleshooting
- Release Notes
Entity Framework Extensions Batch Size
Description
Batch size is the number of records in each batch. The rows in a batch are sent to the server at the end of each batch.
The BatchSize
property gets or sets the number of records to use in a batch. The following example save bulk data in batches of 1000 rows.
context.BulkSaveChanges(options => options.BatchSize = 1000);
- A batch is complete when
BatchSize
rows have been processed or there are no more rows to send to the destination data source. - The default value is zero, which indicates a default by size depending on the provider. For example, 10 000 for SQL Server.
You can also set batch size globally using EntityFrameworkManager.BulkOperationBuilder
.
// Global EntityFrameworkManager.BulkOperationBuilder = builder => builder.BatchSize = 1000;
Purpose
Having access to modify the BatchSize
default value may be useful in some occasions where the performance is very affected.
Don't try to optimize it if your application is not affected by the performance problem.
FAQ
What's the optimized BatchSize?
Not too low, not too high!
Unfortunately, there is no magic value.
- If you set it too low, the library will perform too many round-trips and it may decrease the overall performance.
- If you set it too high, the library will make fewer round-trips, but it could decrease the overall performance by taking more time to write on the server.
There is no perfect number since there are too many factors such as:
- Column Size
- Index
- Latency
- Trigger
- Etc.
Author: ZZZ Projects