SendStringParametersAsUnicode parameter not working
SendStringParametersAsUnicode attribute is set to "false" after the JDBC use prepareStatement SQL execution CHAR type query still very slowly
Based on SqlServer2008, the JDBC driver version is 6.2.2.jre8
Through a series of validation, in fact, in a single primary key OR query, actual sendStringParametersAsUnicode attribute is set to "false" is to take effect.
For example, the following SQL precompiled can take effect, The speed is normal.
Note that the ID here is of the char type, and this SQL will be slow before the property is configured
SELECT * FROM FS_InpatientContact WHERE ([ID]=?) OR ([ID]=?) OR ([ID]=?) OR ([ID]=?) OR ([ID]=?)......
However, this property seems to be invalid in another table query, where ITEM_CODE is of type char and REP_NO is of type numeric. Therefore, I speculate that it may have failed in the case of multiple primary keys.
SELECT * FROM AS_REPENTRY WHERE ([ITEM_CODE]=? AND [REP_NO]=?) OR ([ITEM_CODE]=? AND [REP_NO]=?) OR ([ITEM_CODE]=? AND [REP_NO]=?)......
With this in mind I Debug the source code
Through the debug source setObject method, which can be found in fact sendStringParametersAsUnicode properties of false was effective. However, when actually sent to the server, it should still be in Unicode format, so the conversion will be time-consuming, resulting in extremely slow SQL queries.
This problem is more obvious in the larger the data volume of the table
Above is my investigation process, but also hope guys to give some advice