| Start |
|---|
| JSON stored as text column JSON is textual format, so it is stored in standard NVARCHAR columns. NoSQL collection is equivalent to two column key value table: Use |
| Ensure that JSON is properly formatted using ISJSON Since JSON is stored textual column, you might want to ensure that it is properly formatted. You can add CHECK constraint on JSON column that checks is text properly formatted JSON: If you already have a table, you can add check constraint using the ALTER TABLE statement: |
| Expose values from JSON text as computed columns You can expose values from JSON column as computed columns: If you add PERSISTED computed column, value from JSON text will be materialized in this column. This way your queries can faster read value from JSON text because no parsing is needed. Each time JSON in this row changes, value will be re-calculated. |
| Adding index on JSON path Queries that filter or sort data by some value in JSON column usually use full table scan. To optimize these kind of queries, you can add non-persisted computed column that exposes JSON expression used in filter or sort (in this example JSON_VALUE(Data, '$.Color')), and create index on this column: Queries will use the index instead of plain table scan. |
| JSON stored in in-memory tables If you can use memory-optimized tables, you can store JSON as text: Advantages of JSON in in-memory:
|
Read Article
https://develop.horje.com/learn/1434/reference