-
Notifications
You must be signed in to change notification settings - Fork 426
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
Performance | Improve performance of SQLServerDataTable.internalAddRow() function #990
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #990 +/- ##
============================================
- Coverage 53.01% 53.01% -0.01%
- Complexity 3158 3161 +3
============================================
Files 119 119
Lines 28022 28023 +1
Branches 4688 4680 -8
============================================
Hits 14857 14857
- Misses 10928 10942 +14
+ Partials 2237 2224 -13
Continue to review full report at Codecov.
|
I recreated the original PR #538 for improving performance in SQLServerDataTable considering regression scenarios and what we discussed before. I have added tests to cover discussed cases. Note: I relooked over allowing custom object types when adding row data, and I think that should be supported as it is. The underlying datatype being passed decides the type of the value added to the column and should work as expected. Let me know if you have any concerns. |
Hi @cheenamalhotra. Thanks for revisiting this. Initial thoughts are that having some tests around this is great. On performance though this PR still leaves lots of cases which go via string serialization. For example using a The type-testing approach I suggested in this comment on the previous PR handles all these cases and more - do you have an objection to it? (defaulting to using |
Hi @alexnixon I considered that before but it increases code complexity and performs conversions even when not needed (which impacts performance for corresponding types). With this change, we do give maximum performance for corresponding datatypes, but for values whose datatypes do not correspond to JDBC Type, we support them by converting to String generically... which seems a fair deal to me. It is not something that we recommend for users either way and need not overload implementation for all such possibilities. |
Could you give me specific example of an unneeded conversion? I'm struggling to see any case in which my suggestion is slower[1] but can see many important cases which are substantially faster (e.g. the aforementioned using an I know performance isn't often a big deal but these cases are abysmally slow and given the client is using TVPs it's not unlikely they're shoveling large amount of data through here. [1] unless you count the |
@alexnixon I believe @cheenamalhotra is referring to all the instance of checks that end up happening. I believe the complexity tradeoff is fair. In most (all?) cases I'm matching the types up anyways. Even if I didn't do that, I could make the decision to do it at the point of creating the TVP to get better performance with @cheenamalhotra's implementation (I could handle the up/down casting myself) |
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what sort of approve authority I have, even if the small changes I suggested aren't implemented I think things look fine.
@alexnixon There are many computations going on in that approach, and I think its fair to keep the implementation less complicated inside driver. e.g. working with all Numeric types as Long and then converting them to Short/Integer class objects, etc. also opens up endless possibilities with other types too, whereas it doesn't give much of an advantage vs its need for end user. And as far as performance is concerned, I agree the corresponding types must be quickly passed through and hence this change is well deserved. @cogman Thanks, I made quick modifications as per your suggestions. It looks clean now. |
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java
Outdated
Show resolved
Hide resolved
src/test/java/com/microsoft/sqlserver/jdbc/tvp/TVPTypesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/microsoft/sqlserver/jdbc/tvp/TVPTypesTest.java
Outdated
Show resolved
Hide resolved
src/test/java/com/microsoft/sqlserver/jdbc/tvp/TVPTypesTest.java
Outdated
Show resolved
Hide resolved
# Conflicts: # src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataTable.java
0e8bb83
Fixes issue #531 and #539
Rework of PR #538