我正在尝试对小型 ATS(500 个实体)上的搜索/读取和插入查询进行基准测试。平均插入时间为 400 毫秒,平均搜索 + 检索时间为 190 毫秒。
插入时,我正在查询分区键,并且条件本身仅由一个谓词组成:[PartitionKey] eq <value>
(不再有和/或)。另外,我只退回 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();
最佳答案
您可以引用这篇文章了解可能的性能问题:Microsoft Azure Storage Performance and Scalability Checklist .
您只能获得一个属性的原因是您正在使用 EntityResolver ,请尝试删除它。引用Windows Azure Storage Client Library 2.0 Tables Deep Dive用于 EntityResolver 的使用- 什么时候应该使用它以及如何正确使用它。
关于azure - 小表上的 Azure 表搜索和插入操作速度缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30816338/