DocumentDB Query Requires Unexpected High RUs

怎甘沉沦 提交于 2019-12-11 04:50:32

问题


I have about 200MB of data stored in a S3 document collection (the highest one). Each document is about 300KB in size.

But when I ran my query, I am surprised to see that it requires 7245.81 RUs. Because S3 is at 2500 RUs/Second, this performance won't scale for my application.

I just want to ask if I am doing anything wrong and if there is anything that I can do to improve it?

My query is like this:

SELECT item.Id,item.Priority, va.something, wa.something... 11 fields in total
FROM model.Item item 
JOIN va in item.Content.Children 
JOIN wa in va.Children 
WHERE item.State != 5

I am using "Range" as the index type. Would that impact the performance of this query?


回答1:


Queries using != will require a scan, since all index entries have to be looked up to eliminate the values that are not equal to 5. This will lead to a high RUs. Whenever possible, please try rewriting the query as an equality or a range query.

  1. If the number of possible values of item.State is limited, e.g., 1-10, then you can enumerate the valid values using IN, i.e., item.State IN (1,2,3,4,6,7,8,9,10)
  2. If that's not possible, the please use ranges e.g., item.State > 5 OR item.State < 5 like suggested by Larry above.

Hope this helps. Please email me at arramac at microsoft dot com in case you'd like to discuss in more detail.



来源:https://stackoverflow.com/questions/30541280/documentdb-query-requires-unexpected-high-rus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!