-
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
Speed up insert operation (BulkSaveChanges) #15059
Comments
You can do that with linq2db extension right now if you can't wait EF Core implementation. With this extension you will be able to insert any query in any table, even in temporary and then reuse it in linq query. And for reporting you will quickly find that you need more SQL extensions which are provided by linq2db out of the box. |
@MaklaCof When you say, "In my case, the factor between SaveChanges and BulkSaveChanges is even greater then," can you provide some details? What have you tested and what were the results? |
@MaklaCof Also, can you post the version of EF Core that you are using, and the database provider that you are using? |
Of course. I will need a day or two. I am on the tight schedule until Wednesday. Out of my head, version was 2.1 (currently I am on 2.2), and provider was SQL Server express 2016 (currently I use SQL Server Developer 2017). |
Hi, I made a demo in which ratio is not so much, but the case is simple and repeatable. The difference I mentioned occurs when the table has 20-50 columns, and it has several relational data and not just one as in a demo.
As we can see, with 10000 rows, Database is SQL Server Developer 2017 in local network on HP server with two 1Gb network card. Here is source code. |
This seems to be comparing EF Core's regular |
@MaklaCof Thanks for the additional information. A few comments:
|
Hi, I will update thread when I get back to the real life scenario, where I experience larger factor. |
Are there any plans for implementing this? Inserting large numbers of rows in EFCore is painful. |
@Mikilll94 Can you share the numbers you are seeing using the current EF Core batching implementation? |
Note #27372 which will substantially improve our standard insert perf on SQL Server in 7.0. We also have #27333 for adding a dedicated API for bulk importing (e.g. SqlBulkCopy); we can probably close this as a dup of that. One last idea... We also have #9118 for optionally not tracking after SaveChanges; which would unlock using SqlBulkCopy for standard SaveChanges. At that point, the advantage of a dedicated bulk import API (#27333) becomes bypassing the change tracking machinery, which may or may not be worth it. |
EFCore.BulkExtensions as of recently has BulkSaveChanges as well, among other CRUD Bulk ops. |
I know, have been following Execute issue. |
@borisdj if you promote your library, be transparent and put a disclaimer in all your post saying it's not free + link to your pricing https://www.codis.tech/efcorebulk/. I lost my time by trying your solution... I had to undo my code because our company doesn't want to pay $1000 for your license!!! |
License was recently updated from fully free to semi free and the post is much older (plus the issue is closed) |
Currently inserting thousands (1000, 10000, 100000) of records is really slow. I think there is room for improvement, so I am creating feature request for bulk SaveChanges.
Inspiration came form (EntityFramework Extensions).
In my case, the factor between
SaveChanges
andBulkSaveChanges
is even greater then:I think this is somehow related with #9270 and #795, but not duplicated. (I might be mistaken.)
Use case:
The text was updated successfully, but these errors were encountered: