是否Azure存储表查询实体真的有数量限制? [英] Does the Azure Storage Table query entities really has number limitations?

查看:199
本文介绍了是否Azure存储表查询实体真的有数量限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MSDN ,似乎有一个限制的通过查询服务返回的实体数量:

From MSDN, it seems there's a limitation for the number of entities returned by the Query service:

对阵表服务的查询可以在同一时间最多1000实体的返回,并可以执行最多的五秒钟。

A query against the Table service may return a maximum of 1,000 entities at one time and may execute for a maximum of five seconds.

但正如我写了一个样本,以显示这个问题,我没有找到返回的实体数量的任何限制,这里是我的钥匙code:

But as I wrote a sample to show this issue, I didn't find any limitations for the number of returned entities, here is my key code:

public class DataProvider
{
    public static string PartitionKey
    {
        get { return "PartitionKey"; }
    }

    public static IEnumerable<CustomerEntity> MoreThanThousandData()
    {
        var result = new List<CustomerEntity>();
        for (int i = 0; i < 1200; i++)
        {
            result.Add(new CustomerEntity(PartitionKey, Guid.NewGuid().ToString())
            {
                Name = Guid.NewGuid().ToString(),
                Age = new Random().Next(10, 70)
            });
        }

        return result;
    }
}

1200插入实​​体表:

Insert 1200 entities to the table:

public class AfterOptimize
{
    public void InsertDataToTable()
    {
        var cloudData = DataProvider.MoreThanThousandData();
        Console.WriteLine("Plan to insert {0} entities to the table.", cloudData.Count());

        InsertDataToTableInternal(AzureTableService.Table, cloudData);
    }

    private void InsertDataToTableInternal(CloudTable table, IEnumerable<ITableEntity> data)
    {
        var splitedData = data.Chunk(100);
        Parallel.ForEach(splitedData, item =>
        {
            var batchInsertOperation = new TableBatchOperation();
            foreach (var tableEntity in item)
            {
                batchInsertOperation.Add(TableOperation.Insert(tableEntity));
            }

            table.ExecuteBatch(batchInsertOperation);
        });
    }
}

然后,从表中读出,分区键都是相同的位置:

Then, read from the table, the partition key are all the same here:

public void ReadCloudData()
{
    InsertMoreThanOneThousandDataToTable();
    var query =
        new TableQuery<CustomerEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey",
            QueryComparisons.Equal, DataProvider.PartitionKey));
    var result = AzureTableService.Table.ExecuteQuery(query);
    Console.WriteLine("Read {0} entities from table.", result.Count()); // output 1200
}

我只使用了最新的Azure存储.NET客户端API。

I only used the latest Azure storage .NET client API.

推荐答案

我无法找到一个文档链接,但的executeQuery 方法处理延续标记内部,并将返回表中的所有实体。因此,您所看到的行为是正确的。

I'm not able to find a documentation link but ExecuteQuery method handles continuation token internally and will return all entities in a table. Thus the behavior you're seeing is correct.

如果您,当您在执行此code运行提琴手,你会发现多个请求被发送到餐桌服务。首先要求将没有延续标记,但在后续请求中,您将看到 NextPartitionKey NextRowKey 查询字符串参数。

If you run Fiddler when you are executing this code, you will notice multiple requests are sent to table service. First request would be without continuation token but in subsequent requests you will see NextPartitionKey and NextRowKey querystring parameters.

这篇关于是否Azure存储表查询实体真的有数量限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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