Azure DocumentDB .NET SDK文档查询API提供了按精度降低订单的选项,但确切的预期效果仍然不明确。 文档仅说明:
获取或设置Azure DocumentDB数据库服务中启用低精度排序的选项。
ORDER BY子句文档没有说明有关排序行为的信息,具体取决于FeedOptions或结果有时的排序方式与查询中请求的不同。
提到的选项实际上做了什么? 使用“低精度”时我们可以期望什么精度? 我们可以断言超越“低精度”的实际顺序?Azure DocumentDB .NET SDK document querying API provide option to reduce order by precision but the exact expected effect remains vague. The documentation states only:
Gets or sets the option to enable low precision order by in the Azure DocumentDB database service.
The ORDER BY-clause documentation does not say a word about ordering behavior depending on FeedOptions or results being sometimes ordered differently than requested in query.
What does the mentioned option actually do? What precision can we expect when using "low precision"? What can we assert about the actual order beyond that "low precision"?最满意答案
Azure Cosmos DB支持改变索引的精度以减少索引的存储占用空间(默认为全精度)。 例如,数字精度为5,该服务将索引数字的前5个字节。
默认情况下,不允许对精度较低的属性进行排序。 但您可以通过设置EnableLowPrecisionOrderBy来选择执行ORDER BY。 假设您选择数字精度为5(对于8字节数字)。 查询结果将按照该数字的最高有效5个字节的顺序排列,但保证其余3个字节没有顺序。 此选项允许您执行快速排序,而无需完全精确索引,例如,当您执行临时数据探索时。
对于大多数用例,您应该使用默认精度,而不必依赖于精度较低的顺序。
Azure Cosmos DB supports varying the precision of your index to reduce the storage footprint of indexing (default is full precision). For example, with a numeric precision of 5, the service would index the first 5 bytes of your number.
By default, sorting a property with a lower precision is disallowed. But you can opt-in to perform an ORDER BY by setting EnableLowPrecisionOrderBy. Let's say you choose a numeric precision of 5 (for an 8-byte number). The query results will be in order based on the most significant 5 bytes of the number, but guarantees no order for the remaining 3 bytes. This option lets you perform fast order by without requiring full precision indexing, for example, when you're performing ad-hoc exploration of data.
For most use cases, you should use the default precision, and not have to rely on the lower precision order by.
EDIT: this is now deprecated, and indexing is by default maximum precision
更多推荐
发布评论