Skip to content
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

Bulk insert support? #23

Open
thomaswolff opened this issue Apr 17, 2020 · 4 comments
Open

Bulk insert support? #23

thomaswolff opened this issue Apr 17, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@thomaswolff
Copy link

thomaswolff commented Apr 17, 2020

Hi,

What is the fastest (and recommended) way of doing bulk insert using MightyOrm?

I've tried the public override IEnumerable<T> Insert(IEnumerable<object> items) method. However, it doesn't seem very fast. As of writing this, I'm inserting 100K rows in total, and it has taken several minutes reaching 20K.

Update: It took over an hour inserting 100 000K rows (15 columns).

Any inputs on this?

Thanks,
Thomas

@mikebeaton
Copy link
Member

Hi. It's not recommended for bulk insert - it's aimed at detecting and updating, or inserting in this case, the changes in a reasonable number (say 100's) of business objects. It works one object at a time, and there's definitely no code in Mighty (or Massive) that tries to optimise for bulk insert. I'd need to do some research myself as to what the most efficient way is to achieve this using system.data.common.

@mikebeaton
Copy link
Member

I'm noting/reminding myself that this is something done in quite DB specific ways:

Mighty (following Massive) is a wrapper over system.data.common, mainly; although Mighty does already add a few new features, such as cursors and Npgsql dereferencing, which aren't in system.data.common at all.

So basically, adding a bulk insert wrapper - whilst certainly possible, and not unreasonable! - is 100% a new feature which Mighty doesn't have! :-/

@thomaswolff
Copy link
Author

Thanks for the update @mikebeaton

My investigation also concluded in using the SqlBulkCopy class for this situation, so I have opted for doing that.

Maybe this issue can be marked as an enhancement?

@mikebeaton mikebeaton added the enhancement New feature or request label Apr 21, 2020
@mikebeaton mikebeaton changed the title Insert performance Bulk insert support? Apr 21, 2020
@mikebeaton
Copy link
Member

Maybe this issue can be marked as an enhancement?

Happy to do that - in fact, done!

A couple of points:

  • I'm currently thinking of this as a fairly niche requirement - any good business/use case/website examples of where bulk insert makes a lot of sense and is something you'd do a lot would be helpful! (To me!)
  • I'd definitely want to do this (or, for it to be done) in a way which covers all the existing ADO.NET drivers which have bulk insert support
  • If anyone else reading this would like/could use bulk insert support, please thumbs up here or add a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants