最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

json - SQL - How to speed up a query execution while using JSON_Value in WHERE clause - Stack Overflow

programmeradmin0浏览0评论

So, we have a SQL table named Clients which has the following columns:

  1. UniqueId (nvarchar(200), not null)
  2. Data (nvarchar(max), null) - this one has JSON for each row(aprox. 30k-40k characters)

And we got a request to return to our user, UniqueId using the value from one of the parameters nested in Data JSON field (let's call it Value in this example)

We got something like this:

select UniqueId
from dbo.Clients 
where JSON_VALUE(Data,'$.Parent.Child.ChildOfChild.Value') like 'Value'

But, as expected, table which has 20k+ rows and each row contains JSON in Data(with 30k-40k characters) takes a very long time to execute.

Our question is, is there any way to speed up this kind of query? Given the fact that we can't change the table design. Thanks in advance!

发布评论

评论列表(0)

  1. 暂无评论