Open
Description
SQL Server has a historic flaw where UTF-8 bind values are supported by implicit conversion to NVARCHAR
behind the scenes by the mssql-jdbc driver. This can lead to significant performance issues, as the auto conversion tends to prevent index usage on VARCHAR
columns:
- Parameters os String type are being passed as nvarchar even for varchar columns. This is effecting Query plan and making it significantly slow. #11537
- Consider changing the default value for sendStringParametersAsUnicode microsoft/mssql-jdbc#1538
- https://x.com/stolsvik/status/1849925861161771298
jOOQ could help users work around this problem by automatically casting all VARCHAR
bind values to VARCHAR
explicitly making sure the NVARCHAR
value transmitted over the wire doesn't produce the indexing problem. We'd have to make sure:
- That UTF-8 is still applied correctly
- This isn't applicable for
NVARCHAR
types, which don't have this issue - Possibly, the feature needs to be configurable with a
Settings
Given the potential regression risk (encoding problems, for example), I'm not sure yet whether jOOQ should take action here. Users can implement their own data type binding to implement this cast for their VARCHAR
columns easily.
Activity