c# - 从 CosmosDB 获取最大数量的有效方法
问题描述
我有大量文件(约 200 万份)。我必须查询num
给定字典键的最高值。
以下两个文档的预期输出将是'3'
给定的 key '85642768'
。
文件1:
{
"id": "fb41ecd9-2761-41f4-87ca-aa4bf59f9d83",
"Key": "Key123",
"Dict": {
"85642766": {
"num": 1,
"str": "str1"
},
"85642767": {
"num": 1,
"str": "str2"
},
"85642768": {
"num": 2,
"str": "str3"
}
}
}
文件2:
{
"id": "821cf017-421a-422a-b082-45e77228dca3",
"Key": "Key456",
"Dict": {
"85642766": {
"num": 1,
"str": "str1"
},
"85642767": {
"num": 2,
"str": "str2"
},
"85642768": {
"num": 3,
"str": "str3"
}
}
}
目前我有 250K 的唯一文档。我正在根据Key
8000 个批次的列表下载文档列表。在同一位置需要 14 分钟,10000 个 RU。
我也有一个基于的索引Key
。有没有更好的方法来减少搜索时间?
解决方案
正如上面的评论所说,你可以使用 sql 来做这件事。
请尝试类似这样的 sql:
SELECT value max(c.Dict["85642768"].num) from c
希望这可以帮到你。
推荐阅读
- c# - Application.Current 为空,但 new Application() 仍然失败?
- c# - 连接到共享网络资源并不总是有效
- python - 修改 Seaborn Violinplot 以显示意味着不是中位数
- javascript - 无法访问 javascript 变量值
- bash - 如何用bash递归查找和替换整个文件?
- apache - 如何在 Amazon Linux 上运行的 Apache 2.4.39 Apache 配置中取消设置(隐藏)“服务器”标头
- java - 如何处理大量查询参数的 if/else 语句(例如过滤器)
- processing - 为什么我得到这样的错误nullpointerexception?
- simulation - 模拟相关随机变量的 Cholesky 分解
- python - 如何使用 Python 将 CSV 数据从宽格式转换为长数据集