-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add batch bulk insert, refactor insert #14
base: dev-0.5.0
Are you sure you want to change the base?
Conversation
Tests have not yet been made
This is built on my other request branch, so it needs to be pulled after that or refactored. |
In my testing, if using HikariCP, batch is by far the fastest. |
@Sylvyrfysh, this is awesome. Give me until tomorrow to merge it in. I was doing some fire hose cleanup in 0.5.0 thinking I have a day or two before releasing a new version. I left some original code from KotliQuery and focused on adding much needed features. Now going through the code I decided it was time to do some cleanup of its limitations and unnecessary overheads, take care of kludges I added and add some syntactic sugar (I thought) which turned out to be an improved parameter type preservation mechanism. I too found that Here is the extract from version history for the version committed to dev-0.5.0: 0.5.0-beta-8
I will continue working on it tomorrow and merge your changes into the code. |
Sounds good! I am no SQL expert myself. and will trust that you'll update things as they come. I'm mostly adding things that are of use in my Database Systems class for this one project, and will continue contributing as long as I can. I've found a couple of issues around HikariCP and default schemas that I might contribute if I can both find the issue and fix it, otherwise I'll open an issue. Thank you for creating as much as you have though, this is much nicer than a standard Java API! |
This is how this project got started and evolved. I did it originally trying to convince a client to ditch Scala Slick because it is to SQL what pig-latin is to English. Unfortunately they did not go for it thinking it will delay the project. Reality is the reverse and in the last two years I wasted a lot of (billable) time trying to figure out how to do a simple SQL query in Scala Slick. In the end it always comes out undecipherable gibberish only a Scala disciple can unravel. I appreciate all input and contributions. My time of these days is scarce and I wish I could spend more on it. Kotlin has enough flexibility to make a very intuitive SQL API. |
@Sylvyrfysh, I will add my comments and questions. I like the idea because bulk and batch inserts work so much faster. This is especially noticeable over remote DB connections. However, I am not sure if the current implementation addresses the general use cases. |
I don't know that it does, but with 0.5.0 and releasing the companion, I'm not sure of a better way |
@Sylvyrfysh, I will think about it but can see one way is to group the model instances by matched insert column list. Then all the models in the group can be bulk inserted and the code will work for all model definitions. I am not sure about the batch insert since I never used it but is this not just a driver optimization to send multiple inserts as a single request or does it too have one insert column list followed by multiple sets of insert values? |
This begins adding batch and bulk insert operations, which on data size of 250 items, increase performance by 5% and 5000%, respectively. Since bulk does things so much better, I considered dropping batch, but it may be necessary in some situations I do not yet know about.
I have marked this as not ready for pull for 2 reasons:
Let me know if you'd like anything changed, or feel free to make them yourself.