Azure表存储存储多种类型 [英] Azure table storage store multiple types

查看:143
本文介绍了Azure表存储存储多种类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下情况下,您有什么建议?

What do you recommend in the following scenario:

我有一个名为Users的天蓝色表,其中as列为:

I have an azure table called Users where as columns are:

  • 主键
  • RowKey
  • 时间戳
  • 名字
  • 姓氏
  • 电子邮件
  • 电话

然后,每个用户有不同类型的任务,我们将它们称为TaskType1和TaskType2.

Then there are different types of tasks for each user let's call them TaskType1 and TaskType2.

两种任务类型都有共同的列,但又有特定于类型的列,如下所示:

Both task types have common columns but then have also type specific columns like this:

  • PrimaryKey(与用于查找属于一个用户的所有任务的Users PrimaryKey相同)
  • RowKey
  • 时间戳
  • 名称
  • DueDate
  • 说明
  • 优先

然后TaskType1具有其他列:

then TaskType1 has additional columns:

  • EstimationCompletionDate
  • 可行

,TaskType2有其自己的特定列:

and TaskType2 has it's own specific column:

  • 估计成本

我知道我可以将两种类型存储在同一张表中,而我的问题是:

I know I can store both types in the same table and my question is:

如果我对TaskType1和TaskType2使用不同的表,那么对交易成本的影响是什么?我会猜测,如果每种任务类型都有2个表,然后发出类似get me all tasks where the task Primarykey is equal to a specific user from Users table PrimaryKey的查询,那么我将必须为每种类型运行2个查询(因为用户可以同时拥有两种任务类型),这意味着需要更多的事务. ..相反,如果两个任务都在同一个表中,则它将像1个查询(在分页事务之后的限制为1000个),因为我将获得PartitionKey是用户PartitionKey的所有行,因此该分区不会被拆分,这意味着有1笔交易吗?

If I use different tables for TaskType1 and TaskType2 what will be the impact in transactions costs? I will guess that if I have 2 tables for each task type and then I will issue a query like: get me all tasks where the task Primarykey is equal to a specific user from Users table PrimaryKey then I will have to run 2 queries for each types (because users can have both tasks type) that means more transactions ... instead if both tasks are in the same table then it will be like 1 query (in the limit of 1000 after pagination transactions) because I will get all the rows where the PartitionKey is the user PartitionKey so the partition is not split that means 1 transaction right?

所以我正确地理解,如果将任务存储在不同的表中,我将有更多的事务..

So did I understood it right that I will have more transactions if I store the tasks in different tables .. ?

推荐答案

您的理解是完全正确的.将任务拆分为2个单独的表将意味着2个单独的查询,因此2个事务(现在让1000个以上的实体不存在).尽管交易成本是将它们保留在同一张表中的原因之一,但还有其他原因:

Your understanding is completely correct. Having the tasks split into 2 separate tables would mean 2 separate queries thus 2 transactions (let's keep more than 1000 entities out of equation for now). Though transaction cost is one reason to keep them in the same table, there are other reasons too:

  • 通过将它们保存在同一表中,您将充分利用Azure表存储的无模式性质.
  • 2个表表示2个网络呼叫.尽管该服务具有很高的可用性,但是您需要考虑到成功调用第一个表但调用第二个表失败的情况.在这种情况下,您的应用程序将如何运行?您还会从第一张表中丢弃结果吗?通过仅将它们放在一张桌子中,可以避免这种情况的发生.
  • 假设您的应用程序中有一个场景,用户可以同时订阅任务1和2.如果将它们放在同一表中,则可以使用 Entity Group Transaction ,因为两个实体(一个用于任务1,另一个用于任务2)将具有相同的PartitionKey(即用户ID).如果将它们放在单独的表中,则将无法利用实体组事务.

我要提出的一个建议是在任务"表中具有"TaskType"属性.这样一来,您也将拥有一种更轻松的按任务过滤的方法.

One suggestion I would give is to have a "TaskType" attribute in your Tasks table. That way you would have an easier way of filtering by tasks as well.

这篇关于Azure表存储存储多种类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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