检索使用TableBatchOperation多行不支持? [英] Retrieving many rows using a TableBatchOperation is not supported?

查看:165
本文介绍了检索使用TableBatchOperation多行不支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是一块$ C $的c是初始化设计在单个批次中检索两排TableBatchOperation:

Here is a piece of code that initialize a TableBatchOperation designed to retrieve two rows in a single batch:

 TableBatchOperation batch = new TableBatchOperation();
 batch.Add(TableOperation.Retrieve("somePartition", "rowKey1"));
 batch.Add(TableOperation.Retrieve("somePartition", "rowKey2")); 
 //second call throws an ArgumentException:
 //"A batch transaction with a retrieve operation cannot contain 
 //any other operation"

作为mentionned,抛出一个异常,似乎不支持在单个批处理以获取N行。
这是一个大问题给我,因为我需要检索每个请求大约50行。 这个问题是尽可能多的性能明智的成本明智的。正如你可能知道,Azure Table中存储的定价是基于交易的金额,这意味着50检索操作的50倍,单批更贵操作。

As mentionned, an exception is thrown, and it seems not supported to retrieve N rows in a single batch. This is a big deal to me, as I need to retrieve about 50 rows per request. This issue is as much performance wise as cost wise. As you may know, Azure Table Storage pricing is based on the amount of transactions, which means that 50 retrieve operations is 50 times more expensive than a single batch operation.

有我错过了什么?

边注
我使用的是新的Azure存储API 2.0。
我已经注意到这个问题从未被提出在网络上。这个约束可能最近添加?

Side note I'm using the new Azure Storage api 2.0. I've noticed this question has never been raised on the web. This constraint might have been added recently?

修改

我发现了一个相关的问题在这里:<一href=\"http://stackoverflow.com/questions/11966450/very-slow-on-azure-table-storage-query-on-partitionkey-rowkey-list\">Very慢Azure上表的存储查询的PartitionKey / RowKey列表。
看来使用TableQuery用或上rowkeys将与全表扫描的结果。
这确实一个严重的问题在这里...

I found a related question here: Very Slow on Azure Table Storage Query on PartitionKey/RowKey List. It seems using TableQuery with "or" on rowkeys will results with a full table scan. There's really a serious issue here...

推荐答案

在设计你的分区键(PK)和行键(RK)计划在Azure的表的存储(ATS)你首要考虑的应该是你将如何检索数据。正如你说每次运行查询费都赚钱,但更重要的是时间,所以你需要获取所有数据的后面在一个有效的查询。您可以在ATS运行高效的查询是这些类型的:

When designing your Partition Key (PK) and Row Key (RK) scheme in Azure Table Storage (ATS) your primary consideration should be how you're going to retrieve the data. As you've said each query you run costs both money, but more importantly time so you need to get all of the data back in one efficient query. The efficient queries that you can run on ATS are of these types:


  • 完全PK和RK

  • 完全PK,RK系列

  • PK范围

  • PK范围,RK系列

PK    RK     Data
Guid1 A      {Data:{...}, RelatedRows: [{PK:"Guid2", RK:"B"}, {PK:"Guid3", RK:"C"}]}
Guid2 B      {Data:{...}, RelatedRows: [{PK:"Guid1", RK:"A"}]
Guid3 C      {Data:{...}, RelatedRows: [{PK:"Guid1", RK:"A"}];}

和你在GUID1检索的数据,现在你需要加载GUID2和GUID3。我也presuming,这些行没有共同点喜欢他们都为同一用户。考虑到这一点我想创建一个额外的索引表,这可能是这样的:

and you've retrieved the data at Guid1, and now you need to load Guid2 and Guid3. I'm also presuming that these rows have no common denominator like they're all for the same user. With this in mind I'd create an extra "index table" which could look like this:

PK      RK      Data
Guid1-A Guid2-B {Data:{....}}
Guid1-A Guid3-C {Data:{....}}
Guid2-B Guid1-A {Data:{....}}
Guid2-B Guid1-A {Data:{....}}

其中的PK是合并的PK和母体的RK和RK是子行的组合PK和RK。然后,您可以运行一个查询,它说有PK =GUID1-A返回所有行,你会得到所有相关的数据只需一个电话(或整体两个电话)。这创造最大的开销是在你写,所以现在当你正确的一排你还必须写行对每个相关行也,也确保数据随时更新(这可能不是一个问题你,如果这是一次写入样的情景)。

Where the PK is the combined PK and RK of the parent and the RK is the combined PK and RK of the child row. You can then run a query which says return all rows with PK="Guid1-A" and you will get all related data with just one call (or two calls overall). The biggest overhead this creates is in your writes, so now when you right a row you also have to write rows for each of the related rows as well and also make sure that the data is kept up to date (this may not be an issue for you if this is a write once kind of scenario).

如果任何我的假设是错误的,或者如果你有一些示例数据,我可以更新这个答案与更多的相关的例子。

If any of my assumptions are wrong or if you have some example data I can update this answer with more relevant examples.

这篇关于检索使用TableBatchOperation多行不支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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