当Azure表具有更多记录时ExecuteQuerySegmentedAsync不起作用 [英] ExecuteQuerySegmentedAsync is not working when the Azure table has more records

查看:153
本文介绍了当Azure表具有更多记录时ExecuteQuerySegmentedAsync不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Azure表存储中读取记录.拉记录时我有一个简单的查询

I'm trying to read the records from Azure table storage. I have a simple query while pulling the records

var isPagination = true;
var  combinedFilter = "groupCode eq '9THS'";
var query = new TableQuery<AzStorageEntityAdapter<T>>().Where(combinedFilter);

TableRequestOptions tableRequestOptions = new TableRequestOptions() 
                                            { ServerTimeout = TimeSpan.FromSeconds(90) };

do
{
    var segments = await table.ExecuteQuerySegmentedAsync(query, continuationToken, tableRequestOptions, null);
    currentPageResult.AddRange(segments.Results.Select(s => s.InnerObject).ToList());
    continuationToken = segments.ContinuationToken;
}  while (continuationToken != null && !isPagination);;

一直工作到天青表的记录数较少(10000),且有3到4个不同的Groupcodes为止.

It was working till the azure table had less number of records(10000) with say 3 to 4 distinct Groupcodes.

当表大小增加到超过200000条记录时,搜索将不返回任何记录(即segments.Results具有零条记录,但是continuationToken具有值).

When the table size increased over 200000 records, the search will not return any records (i.e) segments.Results has zero records, but the continuationToken has values.

如果将ExecuteQuerySegmentedAsync替换为ExecuteQuery,它将返回预期的记录.我尝试添加ServerTimeoutMaximumExecutionTime没有任何帮助.

If I replace the the ExecuteQuerySegmentedAsync with ExecuteQuery it returns the expected records. I tried to add ServerTimeout, MaximumExecutionTime nothing helped.

这是怎么了?

推荐答案

这里没有错:).这是预期的行为.

There's nothing wrong here :). It is expected behavior.

来自 Query Timeout and Pagination :

针对Table服务的查询最多可返回1,000个项目 一次最多可以执行五秒钟.如果 结果集包含1,000多个项目(如果查询未包含) 在五秒钟内完成,或者查询是否跨分区 边界,响应包括提供开发人员的标题 与用于继续查询的延续令牌 结果集中的下一项.延续令牌标头可能是 返回查询表操作或查询实体操作.

A query against the Table service may return a maximum of 1,000 items at one time and may execute for a maximum of five seconds. If the result set contains more than 1,000 items, if the query did not complete within five seconds, or if the query crosses the partition boundary, the response includes headers which provide the developer with continuation tokens to use in order to resume the query at the next item in the result set. Continuation token headers may be returned for a Query Tables operation or a Query Entities operation.

基本上,您的查询正在执行全表扫描,因为您没有在查询中指定任何PartitionKey,并且它尝试通过从表的顶部到底部搜索匹配的记录.由于它在5秒钟内没有找到任何匹配的实体,因此仅返回了续用令牌.

Basically your query is doing a full table scan as you have not specified any PartitionKey in your query and it tries to search for matching records by going from top of the table to the bottom. Since it is not finding any matching entities in 5 seconds, it is simply returning the continuation token.

ExecuteQuery起作用的原因是因为它在内部处理了延续令牌.您可以通过在Fiddler中跟踪请求/响应来确认.

As to why ExecuteQuery is working is because it internally handles the continuation token. You can confirm it by tracing the request/response in Fiddler.

这篇关于当Azure表具有更多记录时ExecuteQuerySegmentedAsync不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆