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.
Problem
When transactions are supported, import_data_inner will create a subtransaction for each row.
In bulk mode, no db operations are made anyway so there's no need to for the extra db queries of creating and releasing a save point.
Solution
Do not create save point for each row when bulk mode is enabled.
Acceptance Criteria
Sample bulk_import results (on postgres):
before the changes:
do_create()
Time 6.004
Memory 2.21875
Max 82.12890625 Min 79.91015625
do_update()
Time 5.205
Memory 3.9375
Max 103.12890625 Min 99.19140625
do_delete()
Time 3.548
Memory 0.01171875
Max 105.78125 Min 105.76953125
after the changes:
do_create()
Time 2.2
Memory 2.890625
Max 79.8125 Min 76.921875
do_update()
Time 1.616
Memory 7.921875
Max 101.4609375 Min 93.5390625
do_delete()
Time 0.9456
Memory 0.00390625
Max 104.59765625 Min 104.59375
Significant time decrease. The memory delta is increased, but as you can see with added Max/Min in the output, the overall memory used has not.