improve performance and memory footprint of inserts #216
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on #214, just review changes from last commit.
Previous:
Current:
Allocs were cut in more than a half (almost a third without relationships) and it's slightly faster.
TL;DR: just by removing entirely the Squirrel query builder usage the memory usage was cut in half. We should move away from it as soon as possible, at least for inserts, updates and deletes which are fairly simple without it.
Queries might prove to be slightly more difficult but I still think it's worth the effort if we want to reduce in half the memory footprint of the framework
Note that it still uses the cached statements proxy from Squirrel. When we move away from it, we should either use it or make our own. It's the reason why our version, even being more complicated, it's slightly faster than plain
database/sql
inserts (without prepared statements).