You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Json: add ability to specify type of the json column #28452
E.g. in postgres there are 2 types for json column: json and jsonb. We should allow specifying the type explicitly for each aggregate, once we land on final API
Reacted by Pramod DSilva, Shivam Gupta, rofenix2, pavinil, Jon Samwell, Trystan SARRADE and Rushui Guan
Sorry for reopen but does this mean that i cant change nvarchar(max) for json columns?. Cause that is exactly what i am trying to do according to Microsoft documentation to use nvarchar(4000) for performance reasons.
@cdrfenix can you share some more context? Are you trying to store JSON documents in an nvarchar(4000) column (instead of max)? If so, why? Is it so that you can index the entire JSON document, and if so, how would you be using that index?
@shvmgpt116 some more information on why you need this would be appreciated.
Even tho they tell you twice to use nvarchar(4000) "for performance reasons" it doesnt explain in detail why. So if the reason its only for using a index then i guess i dont have a problem and nvarchar(max) will just do it. Also this article could be relevant in relation to this issue (but not my use case):
Thanks for the links. I'm not enough of a SQL Server expert to know exactly how nvarchar(4000) vs. nvarchar(max) affect performance, but this comment does seem to point to that being important:
The nvarchar(max) data type lets you store JSON documents that are up to 2 GB in size. If you're sure that your JSON documents aren't greater than 8 KB, however, we recommend that you use NVARCHAR(4000) instead of NVARCHAR(max) for performance reasons.
Note that compression (and possibly even columnstore) is a bit orthogonal to this; but also important.
Activity
shvmgpt116 commentedon Jan 30, 2023
@ajcvickers @maumar
When can we expect this feature? Please could someone let me know.
ajcvickers commentedon Jan 30, 2023
We hope to include it in EF8, but that will depend on prioritization against other features. Make sure to vote (👍) for this issue.
rofenix2 commentedon Feb 1, 2023
Sorry for reopen but does this mean that i cant change nvarchar(max) for json columns?. Cause that is exactly what i am trying to do according to Microsoft documentation to use nvarchar(4000) for performance reasons.
roji commentedon Feb 1, 2023
@cdrfenix can you share some more context? Are you trying to store JSON documents in an nvarchar(4000) column (instead of max)? If so, why? Is it so that you can index the entire JSON document, and if so, how would you be using that index?
@shvmgpt116 some more information on why you need this would be appreciated.
rofenix2 commentedon Feb 1, 2023
No i wont index it, i am just trying to follow ms recommendation according to the documentation in here: https://learn.microsoft.com/en-us/sql/relational-databases/json/store-json-documents-in-sql-tables?view=sql-server-ver16
Even tho they tell you twice to use nvarchar(4000) "for performance reasons" it doesnt explain in detail why. So if the reason its only for using a index then i guess i dont have a problem and nvarchar(max) will just do it. Also this article could be relevant in relation to this issue (but not my use case):
https://bornsql.ca/blog/think-twice-about-storing-json-in-your-sql-server-database/
roji commentedon Feb 1, 2023
Thanks for the links. I'm not enough of a SQL Server expert to know exactly how nvarchar(4000) vs. nvarchar(max) affect performance, but this comment does seem to point to that being important:
Note that compression (and possibly even columnstore) is a bit orthogonal to this; but also important.
roji commentedon Apr 30, 2024
Another need here is using varchar instead of nvarchar on SQL Server, especially for UTF8 (raised in #33643).
8 remaining items
Experimental support for the Azure SQL json type
Experimental support for the Azure SQL json type
Experimental support for the Azure SQL JSON type (dotnet#34401)