Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

Querying SQL Server data stored as JSON in column - performance and tips

Hi

Currently I have the following columns
Analog1
Analog2
Analog1Raw
Analog2Raw

I now need to add upto 60 more analog columns, and have decided to switch to one column to store the analog data as

[    
    {
        "an1":2103,
        "an1r":2220
    },

    {
        "an2":5999,
        "an2r":6000
    },
etc..
]

Open in new window


The data is only ever queried by 1 report, but I need the report to be very fast

Therefore I need help with the following
1. what data type should i store the data as in sql server
2. is sql any good at querying this type of JSON data direct

I'll want to do stuff like
select jsonColumn.an1 
where mydate between 2 dates

Open in new window


i'm using .net framework 4.5 so can do other logic here to pull out data, but was hoping to query it directly if its performant

I'm using sql server 2014 on live, 2016 on dev, and we are planning an upgrade to 2017 on both environments.
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In a .NET application, you can add the Newtonsoft.Json NuGet package and then Query the JSON with LINQ.