Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure cosmosdb 为什么查询文档比按id加载文档便宜?_Azure Cosmosdb_Azure Cosmosdb Sqlapi - Fatal编程技术网

Azure cosmosdb 为什么查询文档比按id加载文档便宜?

Azure cosmosdb 为什么查询文档比按id加载文档便宜?,azure-cosmosdb,azure-cosmosdb-sqlapi,Azure Cosmosdb,Azure Cosmosdb Sqlapi,我可以通过使用CosmosDB.NET API client.ReadDocumentSyncDocumentLink从CosmosDB获取特定文档,例如,使用CosmosDB.NET API client.ReadDocumentSyncDocumentLink,或者使用类似sql的语法select*from c将其选中,其中c.id='key'覆盖任何索引键 我使用不同的文件大小,使用C、client Microsoft.Azure.DocumentDB、v2.9.1和真实世界的示例文档,使

我可以通过使用CosmosDB.NET API client.ReadDocumentSyncDocumentLink从CosmosDB获取特定文档,例如,使用CosmosDB.NET API client.ReadDocumentSyncDocumentLink,或者使用类似sql的语法select*from c将其选中,其中c.id='key'覆盖任何索引键

我使用不同的文件大小,使用C、client Microsoft.Azure.DocumentDB、v2.9.1和真实世界的示例文档,使用这两种方法加载相同的完整文档,并获得以下RU成本:

Document size Read Select 1KB 1,00 RU 2,89 RU 6KB 1,33 RU 3,02 RU 100KB 9,95 RU 5,82 RU 200KB 20,29 RU 8,65 RU 请注意,RU成本存在显著差异。它会在你的账单上引起注意

通过这个测试,似乎最好对小文档使用ReadDocumentAPI。好的,这是一个常见的建议

第二种方法是对较大的文档使用select。。这似乎违反直觉,让我变得偏执。关于这是否是故意的,这一页相当含糊

这里有没有我没有考虑到的副作用?或者RU成本函数只是没有很好地反映出几乎相等的实际运营成本

编辑:
Select RU USERATION取自query.ExecuteNextAsync响应对象,该对象执行一次,我确实读取了预期的1文档内容。此外,在MS Azure Storage Explorer中执行相同的查询时,我得到了相同的RU使用情况。我当然希望这里没有隐藏的成本。

对于查询,您是否确实通过在ResultTiterator.HasMoreResults上执行while循环来读取数据?并且耗尽迭代器,你只是在计算容器的RU。GetItemQueryIterator?我使用的是旧的API版本,不应该影响RU的使用,在Q中添加了select RU origin详细信息。现在正在调查这个问题。将尽快回复更多详细信息。谢谢