Windows Azure DocumentDB查询Where IN语句 [英] Windows Azure DocumentDB Query Where IN statement

查看:79
本文介绍了Windows Azure DocumentDB查询Where IN语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在DocumentDB查询中使用IN语句?喜欢:

Is possible to use IN statement in DocumentDB query? Like:

SELECT * FROM  c  where c.FormId in(1,2,3,4,5,6,7,8,9,10)

我不想使用OR,因为有限制(只有6个)

I don't want use OR because there are limits (only 6)

where (c.FormId =1 or c.FormId= 2 or c.FormId =3
Or c.FormId = 4  Or c.FormId=5 Or c.FormId=6)

推荐答案

编辑 我们刚刚宣布支持查询中的IN(和其他)关键字 http://azure. microsoft.com/blog/2015/05/06/new-documentdb-sql-keywords-operators-and-functions/

EDIT We just announced support for the IN (and other) keyword in queries http://azure.microsoft.com/blog/2015/05/06/new-documentdb-sql-keywords-operators-and-functions/

今天;有两种方法可以解决这个问题

Today; there are two ways you could approach this

1)编写一个UDF为您完成此操作,并在您选择的内容中使用它

1) Write a UDF to do this for you and use it in your select

2)或者,您可以根据ID分别进行查询,例如,其中FormId = 1,另一个查询,其中FormId = 2,依此类推.

2) Or, you could make separate queries per id E.g. where FormId = 1 and another query where FormId = 2 etc.

我知道这涉及多个服务器往返,但是取决于您的应用程序相对于DocumentDB服务的驻留位置,并行执行多个查询可能不会很糟糕.

I know this involves multiple server roundtrips but depending on where your app resides in relation to the DocumentDB service it probably won't be that bad to execute multiple queries in parallel.

当使用单个谓词发出多个查询时,这样可以使查询超级高效,因为它在默认情况下在属性上使用哈希索引.

When issuing multiple queries with single predicates like this allows the query to be super efficient because it uses the hash index on your properties which are there by default.

在SELECT的WHERE部分中使用UDF将导致执行扫描,这可能导致次优性能和更高的查询费用.

Using a UDF in the WHERE portion of a SELECT will result in a scan being performed which could result in sub optimal performance and higher query charges.

PS.如果您希望看到本机上增加了对IN运算符的支持,请在 http://feedback.azure.com/forums/263030-documentdb/suggestions/6395357-in-operator

PS. if you would like to see support added natively for the IN operator, please go vote for it on http://feedback.azure.com/forums/263030-documentdb/suggestions/6395357-in-operator

这篇关于Windows Azure DocumentDB查询Where IN语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆