Skip to content

Cast SQL Server VARCHAR bind variables to their type, to avoid unnecessary NVARCHAR conversion by mssql-jdbc #17513

Open
@lukaseder

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:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions