Azure Table:在 Azure Table 中存储 guid 的最佳性能是什么?

Azure Table: What is the best performance to store guid in Azure Table?

我只想在行中存储一个值:guid。但我必须设置对:PartitionKey 和 RowKey,所以我的对是: "guidValue"、some_guid PartitionKey 应该是什么:guid 或 const 字符串?

所以结构应该是这样的:

PartitionKey: "guidValue"
RowKey: 951FE9AE-50FA-48F6-96C8-81D10271E36D

PartitionKey: "guidValue"
RowKey: 951FE9AE-50FA-48F6-96C8-81D10271E37D

PartitionKey: "guidValue"
RowKey: 951FE9AE-50FA-48F6-96C8-81D10271E38D

...

或类似的:

PartitionKey: 951FE9AE-50FA-48F6-96C8-81D10271E36D
RowKey: "guidValue"

PartitionKey: 951FE9AE-50FA-48F6-96C8-81D10271E37D
RowKey: "guidValue"

PartitionKey: 951FE9AE-50FA-48F6-96C8-81D10271E38D
RowKey: "guidValue"

?

我的场景是:guid保存一次,读取多次。

你的阅读场景是怎样的?列出所有现有的 GUID?或者检查一个 GUID 是否存在?是否希望一次请求写入多个GUID,节省写入的交易成本,提高写入性能?

第一个选项将使您能够使用 EntityGroupTransaction 批量插入 GUID,但是只有一个分区键的 table 无法对 Azure 存储后端中的多个服务进行负载平衡。如果你想批量插入GUID,而且GUID总数不是太多,我建议你选择选项1;否则,选项 2 更好。

PartitionKey 影响每个存储服务的负载平衡和可扩展性。

https://azure.microsoft.com/en-us/documentation/articles/storage-scalability-targets/#partitions-in-azure-storage 处 table 个实体的描述:

The partition key for an entity is account name + table name + partition key, where the partition key is the value of the required user-defined PartitionKey property for the entity. All entities with the same partition key value are grouped into the same partition and are served by the same partition server. This is an important point to understand in designing your application. Your application should balance the scalability benefits of spreading entities across multiple partitions with the data access advantages of grouping entities in a single partition.

此外,

if you wish to perform batch operations on a group of entities, consider grouping them with the same partition key.

对于可伸缩性和性能目标,我建议您使用第一个结构。