question

kletrv avatar image
kletrv asked

Computed Columns with JSON Properties

I was following this article regarding indexing a JSON column (nvarchar datatype) in SQL Server 2016. The article mentioned we can create a non-clustered index to speed up the query. Since there is no native JSON datatype, it will require first creating a computed (virtual) column then create a non-clustered index on the new computed column. Article for reference: https://msdn.microsoft.com/en-us/library/mt612798.aspx - section "Index JSON properties by using computed columns". The article mentioned that the computed column is non-persisted; thus, no additional storage space will be consumed. However, I do see the computed column in the table schema and am able to use that computed column directly in a where clause. Am I doing something wrong or mis-understood the concept? Best Regards
computed-column
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
DaSiHu avatar image
DaSiHu answered
"I do see the computed column in the table schema and am able to use that computed column directly in a where clause." This is normal behaviour for a computed column. As there is a virtual index on this virtual column, you should be able to interrogate it (with the usual caveats about indexing)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.