Skip to content
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

SQL Server: Add a SQL2019 dialect that supports storing text as Utf8 #1336

Open
ramonsmits opened this issue Nov 16, 2023 · 0 comments
Open

Comments

@ramonsmits
Copy link
Member

ramonsmits commented Nov 16, 2023

Describe the suggested improvement

Is your improvement related to a problem? Please describe.

Currently, outbox transport operations (MessageId, Operations columns), saga data (Datacolumn) and saga string correlation (Correlation_% column) use the nvarchar type.

This requires twice as much storage for most data stored in these columns as SQL Server its nvarchar type uses 16 bit characters.

Supporting varchar UTF8 collation would half the required storage.

Describe the suggested solution

SQL Server 2019 now supports UTF8:

Likely the easiest approach is to:

  1. Clone SqlDialect.cs to Sql2019Dialect.cs and make it inherit from SqlDialect:
  2. Change column definition to UTF8 in the script builder to use an explicit collation that supports UTF8:
  • From: Operations nvarchar(max) not null
  • To: Operations varchar(max) COLLATE Latin1_General_100_CI_AI_SC_UTF8 not null

Describe alternatives you've considered

An alternative is to not use nvarchar but varbinary and convert to utf8 byte structure in the persisted which would also be compatible with older versions of SQL Server.

@ramonsmits ramonsmits changed the title Add a SQL2019 dialect that supports storing text as Utf8 SQL Server: Add a SQL2019 dialect that supports storing text as Utf8 May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant