缓慢的 Azure Table 小表上的搜索和插入操作

Slow Azure Table Search and Insert Operations on small tables

我正在尝试对小型 ATS(500 个实体)进行基准测试 search/read 并插入查询。平均插入时间为 400 毫秒,平均搜索 + 检索时间为 190 毫秒。

插入时,我正在查询分区键,条件本身仅由一个谓词组成:[PartitionKey] eq <value>(不再是 ands/ors)。另外,我只返回 1 属性。

这样的结果可能是什么原因?

搜索码:

TableQuery<DynamicTableEntity> projectionQuery = new TableQuery<DynamicTableEntity>().Select(new string[] { "State" });
        projectionQuery.Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "" + msg.PartitionKey));
        // Define an entity resolver to work with the entity after retrieval.
        EntityResolver<bool?> resolver = (pk, rk, ts, props, etag) => props.ContainsKey("State") ? (props["State"].BooleanValue) : null;
        Stopwatch sw = new Stopwatch();
        sw.Start();
        List<bool?> sList = table.ExecuteQuery(projectionQuery, resolver, null, null).ToList();
        sw.Stop();

插入代码:

CloudTable table = tableClient.GetTableReference("Messages");
        TableOperation insertOperation = TableOperation.Insert(msg);
        Stopwatch sw = new Stopwatch();
        // Execute the insert operation.
        sw.Start();
        table.Execute(insertOperation);
        sw.Stop();

来自SLA Document

Storage

We guarantee that at least 99.99% of the time, we will successfully process requests to read data from Read Access-Geo Redundant Storage (RA-GRS) Accounts, provided that failed attempts to read data from the primary region are retried on the secondary region.

  • We guarantee that at least 99.9% of the time, we will successfully process requests to read data from Locally Redundant Storage (LRS), Zone Redundant Storage (ZRS), and Geo Redundant Storage (GRS) Accounts.

  • We guarantee that at least 99.9% of the time, we will successfully process requests to write data to Locally Redundant Storage (LRS), Zone Redundant Storage (ZRS), and Geo Redundant Storage (GRS) Accounts and Read Access-Geo Redundant Storage (RA-GRS) Accounts.

还有从那里 refereed document:

Table Query / List Operations
Maximum Processing Time: Ten (10) seconds (to complete processing or return a continuation)

没有快速/低响应时间的承诺。也没有任何关于使用较小的表更快的承诺。

您可以参考此 post 以了解可能的性能问题:Microsoft Azure Storage Performance and Scalability Checklist

你只能得到一个 属性 的原因是你正在使用 EntityResolver, please try to remove that. Refer to Windows Azure Storage Client Library 2.0 Tables Deep Dive for the usage of EntityResolver - 你应该在什么时候使用它以及如何正确使用它。