-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How bulk insert with CDC enabled on SQL Server? #24597
Comments
@tecnologer As far as we can tell, this looks like slowness of inserting when using CDC. You might want to try disabling EF Core batching since it is possible CDC doesn't handle large batches of inserts in one go. Beyond that, the performance here is likely to improve with future implementation of #15059, and the associated #9118 and #10443, |
To adjust the batching size (set to 1 to disable batching): https://docs.microsoft.com/en-us/ef/core/performance/efficient-updating#batching |
Ask a question
I'm using SQL Server with Entity Framework Core in an ASP.net Core app.
IHostedService
) service with aThread.Timer
that runs once a week, on theDoWork
of the timer I have async functions (total: 13) to clone a lot of data into the same table (one function per table).The issue is when it tries to save the new data for Table2 (approx 2k new records) Entity Framework never completes the
SaveChangesAsync
this process is blocked and it starts consuming the whole RAM available.I've created a question on Stackoverflow, and I was able to save data calculating all properties on the client-side, but I also had to reduce the number of records. If some table tries to insert more than ~10k the process is blocked on the next table. I mean, if the table1 inserts more than ~10k records when the table2 tries to insert its data (~2k records) the process will be blocked.
How should manage this kind of task?
Include your code
I call the cloner functions like this:
Each cloner function is like this one, there are other functions that require a loop to update randomly FKs:
Include stack traces
There is no stack trace, I've never got an error.
Include verbose output
Include provider and version information
Local:
SQL Server remote:
The text was updated successfully, but these errors were encountered: