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

Enable optimized JSON UTF8 reading/writing #31216

Open
Tracked by #24110
roji opened this issue Jul 10, 2023 · 1 comment
Open
Tracked by #24110

Enable optimized JSON UTF8 reading/writing #31216

roji opened this issue Jul 10, 2023 · 1 comment

Comments

@roji
Copy link
Member

roji commented Jul 10, 2023

Our JSON reading/writing uses Utf8JsonReader/Writer, but currently always does so over UTF16 strings. In other words, for reading we get a string out of DbDataReader, and then encode it into UTF8, build a MemoryStream over that, and then read from that stream (we do something similarly inefficient for writing).

For SQL Server, where a UTF8 property is configured, we should be able to get binary data directly out of SqlClient, possibly in the form of a stream. Assuming that's the case, we can parse JSON directly out of that stream without the current UTF16 conversions and copying.

We can also consider making string properties UTF8 by convention on SQL Server when they're a JSON container (but consider the breaking change and how the transition would work). Note also that UTF8 support was introduced in SQL Server 2019.

For PostgreSQL, UTF8 is configured at the database level, and is also the default; we should enable this optimization there as well.

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

3 participants