-
Notifications
You must be signed in to change notification settings - Fork 448
Description
Driver version
7.4.1.jre12
SQL Server version
Microsoft SQL Server 2017 (RTM-GDR) (KB4505224) - 14.0.2027.2 (X64) Jun 15 2019 00:26:19 Copyright (C) 2017 Microsoft Corporation Enterprise Edition (64-bit) on Windows 10 Enterprise 10.0 (Build 18362: )
Client Operating System
Windows 10 Pro (1909)
JAVA/JVM version
OpenJDK 12.0.2+10
Table schema
A simple table with a few columns and one index
Problem description
We would like to switch from JTDS to MS SQL JDBC driver. The problem is that during long data crunching, the MS SQL driver is much slower. Our data crunching, which includes various other things, takes 77 minutes with JTDS and 104 minutes with MS SQL.
- Expected behaviour: comparable or better performance than JTDS for similar statements.
- Actual behaviour: some statements in MS SQL JDBC driver are much slower. Our simple test case shows 3x-4x slower.
- Any other details that can be helpful: micro benchmarks do not work. It is the state of the database as it evolves during the data crunching that exhibits this behavior. Make any change to the database (drop a table, change an index, remove and re-add a constraint, etc.) and the test case disappears. It may have to do with the computed statistics that JTDS is able to use and not MS SQL. Of course, it may also be a misuse or misconfiguration of the MS SQL JDBC driver...
Reproduction code
I narrowed down the test case to a relatively small backup (14MB, 170MB unzipped) and a Java class.
MSvsJTDS_bak.zip
SqlServerJdbcDriverSlowdownTest.zip
- Load the backup to a SQL Server 2017 instance.
- Set the credentials and server information at the top of the Java file, add JTDS JAR file and MS SQL JDBC JAR file to classpath, and run it.
We got these results:
1st Try:
Total time (ms): 2879 (MS)
Total time (ms): 929 (JTDS)
2nd Try:
Total time (ms): 2885 (MS)
Total time (ms): 888 (JTDS)
3rd Try:
Total time (ms): 2798 (MS)
Total time (ms): 993 (JTDS)
4th Try:
Total time (ms): 3057 (MS)
Total time (ms): 947 (JTDS)
On a different client and host machine, we got:
Total time (ms): 5681 (MS)
Total time (ms): 1516 (JTDS)