问题描述
我在Cosmos DB中有大约10万条记录.我想查询一个字段的不同值,并在我的应用程序的下拉列表中填充它.让我们假设在10万个文档中分布着大约100个唯一字段值.我正在使用存储过程 进行查询,我将页面大小设置为-1以获取最大记录(响应文档大小为4MB ).当我发起一个没有区别的查询时,我得到大约 1.9万条记录( 4 MB限制).在同一时间 一次,如果我使用"distinct"关键字触发了相同的查询,它会为我提供不同的记录,并且该不重复的"将应用于19000条可能的记录中,而不是全部10万条记录中.因此它只返回大约10条记录,而不是可能的 100 .
I have about 100 thousand records in Cosmos DB. I want to query distinct values a field and populate it in a dropdown in my application. Let us assume there are about 100 unique field values spread over the 100 thousand documents. I am using Stored Procedure to query this and I have set the page size to -1 to get the maximum records(Response document size is 4MB). When I fire a query without distinct, I get about 19 thousand records(4 MB limit). At the same time if I fired the same query with distinct keyword, it gives me distinct records, and the distinct applied with in the 19 thousand possible records instead of the entire 100 thousand records. So it returns me only about 10 records instead of the possible 100.
以下是我使用过的查询:
Below is the query I have used:
SELECT r.[[FieldName]] FROM r ->返回19000条记录(响应文档大小为4MB),包含重复项
SELECT r.[[FieldName]] FROM r -> returns 19000 records(Response document size is 4MB) with duplicates
SELECT DISTINCT r.[[FieldName]] FROM r ->在总共10万条记录中可能的100条中,仅返回10条不同的记录.看来它首先选择了19000条记录,而仅对那些19000条记录应用了区别 总共十万.
SELECT DISTINCT r.[[FieldName]] FROM r -> returns only 10 distinct records out of the possible 100 from the total 100 thousand records. It looks like it is picking the 19000 records first and applying distinct only on those 19000 instead of the total 100 thousand.
有人可以帮忙解决此问题吗?
Can someone help with how to fix this issue?
推荐答案
请注意下面的链接并投票.
Please note the link below and vote.
此致
迈克
这篇关于不同查询在Cosmos DB SQL查询中无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!