gpt4 book ai didi

c# - 多次调用 Azure 表存储来请求少于 10 行

转载 作者:行者123 更新时间:2023-12-03 04:48:05 24 4
gpt4 key购买 nike

我们正在使用 TableQuery 查询 Azure 表存储来检索数据。表包含近 50,000 个实体,而我的查询返回的记录少于 10 条。

一切正常。当我们对其进行负载测试时,问题就出现了。为了检索少于 10 条记录,我们的应用将使用 ContinuationToken 发送 5 到 8 条请求链。

问题:如何阻止 Azure 表提供程序发送多个请求(每个请求 5 到 7 秒)以检索少于 10 条记录?注意:只有当我们对应用程序进行负载测试时才会发生这种情况。

App Insights 中清楚地捕获了这些请求。 enter image description here

以下是 App Insights 捕获的表存储请求 URL(前 3 个)。注意:每个请求都需要很长时间才能完成。

https://redacted.table.core.windows.net:443/Redacted?$filter=%28PartitionKey%20eq%20%27RedactedA%27%29%20and%20%28RedactedB%20eq%20%2763601%27%29

https://redacted.table.core.windows.net:443/Redacted?$filter=%28PartitionKey%20eq%20%27RedactedA%27%29%20and%20%28RedactedB%20eq%20%2763601%27%29&NextPartitionKey=1%2112%21WmlwQ29kZXM-&NextRowKey=1%218%21MTU4Nzc-

https://redacted.table.core.windows.net:443/Redacted?$filter=%28PartitionKey%20eq%20%27RedactedA%27%29%20and%20%28RedactedB%20eq%20%2763601%27%29&NextPartitionKey=1%2112%21WmlwQ29kZXM-&NextRowKey=1%218%21MjIzMzY-

这是我们的表查询

TableQuery<DynamicTableEntity> dynamicQuery = cloudTable.CreateQuery<DynamicTableEntity>();
var query = dynamicQuery.Where(x => x.PartitionKey == tableStorageMeta.PartitionKey &&
x.Properties[searchField].StringValue == searchValue).Select(x => x);

最佳答案

Question: How to stop Azure Table Provider from sending multiplerequest for retrieving less than 10 records?

简单的答案是你不能(除了优化你的查询)。为了执行查询,Azure 表存储会分配固定的时间来执行该查询(5 秒)。如果查询执行花费的时间超过此时间,Azure 表存储将返回迄今为止已获取的任何数据(最多 1000 个实体),如果有更多数据可用,它将返回一个继续 token 。

从此link :

A query against the Table service may return a maximum of 1,000 itemsat one time and may execute for a maximum of five seconds. If theresult set contains more than 1,000 items, if the query did notcomplete within five seconds, or if the query crosses the partitionboundary, the response includes headers which provide the developerwith continuation tokens to use in order to resume the query at thenext item in the result set.

关于c# - 多次调用 Azure 表存储来请求少于 10 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68803140/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com