-
Notifications
You must be signed in to change notification settings - Fork 438
Addressed performance issue on Bulk Copy API with batch insert #2735
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2735 +/- ##
============================================
+ Coverage 51.60% 51.70% +0.09%
- Complexity 4083 4106 +23
============================================
Files 149 149
Lines 34242 34239 -3
Branches 5719 5718 -1
============================================
+ Hits 17672 17702 +30
+ Misses 14104 14092 -12
+ Partials 2466 2445 -21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Ananya2
previously approved these changes
Aug 12, 2025
divang
reviewed
Aug 12, 2025
machavan
reviewed
Aug 12, 2025
...test/java/com/microsoft/sqlserver/jdbc/preparedStatement/BatchExecutionWithBulkCopyTest.java
Outdated
Show resolved
Hide resolved
divang
previously approved these changes
Aug 12, 2025
divang
approved these changes
Aug 13, 2025
David-Engel
approved these changes
Aug 13, 2025
Ananya2
approved these changes
Aug 14, 2025
machavan
approved these changes
Aug 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
A GitHub issue was raised highlighting a performance degradation in the Bulk Copy API when using batch inserts
Pre-release 13.1 is slower #2732
The original issue reported was Bulk copy for batch insert destroys data without error #2669
This occurred when inserting string data using the following settings:
Under these conditions, data was inserted in byte array format rather than as readable strings.
Expected behavior
Select StateCode from states -> "OH"
Actual behavior
Select StateCode from states; -> "[B@4b01d9e4"
On top of this a new issue was reported Accented characters saved incorrectly in database when using useBulkCopyForBatchInsert=true and sendStringParametersAsUnicode=false #2721.
When inserting data using useBulkCopyForBatchInsert=true and sendStringParametersAsUnicode=false, names with accented characters were saved incorrectly in the database.
Root Cause
When inserting string data using batch insert for bulk copy with below combinations:
Fix#2704 and Fix#2727 introduced a performance slowdown because of unnecessary conversion from byte array back to string during the bulk copy batch insert operation.
Fix
Modified the logic to avoid sending data as a byte array in the first place when useBulkCopyForBatchInsert=true. As data inserted to destination table is being taken from dtv.value which is byte array.
Post this fix performance has improved significantly.
Testing