Azure cosmosdb ReadItemAsync与GetItemLinqQueryable?

Azure cosmosdb ReadItemAsync与GetItemLinqQueryable?,azure-cosmosdb,Azure Cosmosdb,有没有人对这两种从CosmosDB检索单个对象的方法进行过分析 container.ReadItemAsync<Device>("devices", new PartitionKey(deviceId), null, default); container.ReadItemAsync(“设备”,新分区键(deviceId),null,默认值); VS container.GetItemLinqQueryable(true).Where(a=>a.DeviceId==DeviceI

有没有人对这两种从CosmosDB检索单个对象的方法进行过分析

container.ReadItemAsync<Device>("devices", new PartitionKey(deviceId), null, default);
container.ReadItemAsync(“设备”,新分区键(deviceId),null,默认值);
VS

container.GetItemLinqQueryable(true).Where(a=>a.DeviceId==DeviceId).FirstOrDefault();

我的猜测是ReadItemAsync更快,但有人确切知道吗?

ReadItemAsync不仅更快,而且更便宜

ReadItem执行点读取操作,根据项目大小使用固定数量的(请求单位)。如果项目大小不变,则操作将始终使用相同的RU

ItemLinqQueryable执行查询,这将消耗更多RU(这些RU可能会有所不同),这取决于配置的索引策略。

实际上读取JSON并将其反序列化为强类型C#对象。如果您要将文档作为后端业务逻辑的一部分进行修改,那么使用它最有意义

然而,GetItemLinqQueryable实际上执行的查询会遍历集合,并且与ReadItemAsync相比会花费更多的RU

container.GetItemLinqQueryable<Device>(true).Where(a => a.DeviceId == deviceId).FirstOrDefault();